annotate src/ext/kissfft/test/pstats.c @ 196:da283326bcd3 tip master

Update plugin versions in RDF
author Chris Cannam <cannam@all-day-breakfast.com>
date Fri, 28 Feb 2020 09:43:02 +0000
parents 5ed6e970541b
children
rev   line source
c@174 1 #include <stdio.h>
c@174 2 #include <stdlib.h>
c@174 3 #include <sys/times.h>
c@174 4 #include <sys/types.h>
c@174 5 #include <unistd.h>
c@174 6
c@174 7 #include "pstats.h"
c@174 8
c@174 9 static struct tms tms_beg;
c@174 10 static struct tms tms_end;
c@174 11 static int has_times = 0;
c@174 12
c@174 13
c@174 14 void pstats_init(void)
c@174 15 {
c@174 16 has_times = times(&tms_beg) != -1;
c@174 17 }
c@174 18
c@174 19 static void tms_report(void)
c@174 20 {
c@174 21 double cputime;
c@174 22 if (! has_times )
c@174 23 return;
c@174 24 times(&tms_end);
c@174 25 cputime = ( ((float)tms_end.tms_utime + tms_end.tms_stime + tms_end.tms_cutime + tms_end.tms_cstime ) -
c@174 26 ((float)tms_beg.tms_utime + tms_beg.tms_stime + tms_beg.tms_cutime + tms_beg.tms_cstime ) )
c@174 27 / sysconf(_SC_CLK_TCK);
c@174 28 fprintf(stderr,"\tcputime=%.3f\n" , cputime);
c@174 29 }
c@174 30
c@174 31 static void ps_report(void)
c@174 32 {
c@174 33 char buf[1024];
c@174 34 #ifdef __APPLE__ /* MAC OS X */
c@174 35 sprintf(buf,"ps -o command,majflt,minflt,rss,pagein,vsz -p %d 1>&2",getpid() );
c@174 36 #else /* GNU/Linux */
c@174 37 sprintf(buf,"ps -o comm,majflt,minflt,rss,drs,pagein,sz,trs,vsz %d 1>&2",getpid() );
c@174 38 #endif
c@174 39 if (system( buf )==-1) {
c@174 40 perror("system call to ps failed");
c@174 41 }
c@174 42 }
c@174 43
c@174 44 void pstats_report()
c@174 45 {
c@174 46 ps_report();
c@174 47 tms_report();
c@174 48 }
c@174 49