annotate ext/kissfft/test/pstats.c @ 207:f11ec82227d5
Change that seemed to be needed for emscripten double-precision build to work
author |
Chris Cannam |
date |
Tue, 14 Mar 2017 13:40:50 +0000 |
parents |
76ec2365b250 |
children |
|
rev |
line source |
Chris@184
|
1 #include <stdio.h>
|
Chris@184
|
2 #include <stdlib.h>
|
Chris@184
|
3 #include <sys/times.h>
|
Chris@184
|
4 #include <sys/types.h>
|
Chris@184
|
5 #include <unistd.h>
|
Chris@184
|
6
|
Chris@184
|
7 #include "pstats.h"
|
Chris@184
|
8
|
Chris@184
|
9 static struct tms tms_beg;
|
Chris@184
|
10 static struct tms tms_end;
|
Chris@184
|
11 static int has_times = 0;
|
Chris@184
|
12
|
Chris@184
|
13
|
Chris@184
|
14 void pstats_init(void)
|
Chris@184
|
15 {
|
Chris@184
|
16 has_times = times(&tms_beg) != -1;
|
Chris@184
|
17 }
|
Chris@184
|
18
|
Chris@184
|
19 static void tms_report(void)
|
Chris@184
|
20 {
|
Chris@184
|
21 double cputime;
|
Chris@184
|
22 if (! has_times )
|
Chris@184
|
23 return;
|
Chris@184
|
24 times(&tms_end);
|
Chris@184
|
25 cputime = ( ((float)tms_end.tms_utime + tms_end.tms_stime + tms_end.tms_cutime + tms_end.tms_cstime ) -
|
Chris@184
|
26 ((float)tms_beg.tms_utime + tms_beg.tms_stime + tms_beg.tms_cutime + tms_beg.tms_cstime ) )
|
Chris@184
|
27 / sysconf(_SC_CLK_TCK);
|
Chris@184
|
28 fprintf(stderr,"\tcputime=%.3f\n" , cputime);
|
Chris@184
|
29 }
|
Chris@184
|
30
|
Chris@184
|
31 static void ps_report(void)
|
Chris@184
|
32 {
|
Chris@184
|
33 char buf[1024];
|
Chris@184
|
34 #ifdef __APPLE__ /* MAC OS X */
|
Chris@184
|
35 sprintf(buf,"ps -o command,majflt,minflt,rss,pagein,vsz -p %d 1>&2",getpid() );
|
Chris@184
|
36 #else /* GNU/Linux */
|
Chris@184
|
37 sprintf(buf,"ps -o comm,majflt,minflt,rss,drs,pagein,sz,trs,vsz %d 1>&2",getpid() );
|
Chris@184
|
38 #endif
|
Chris@184
|
39 if (system( buf )==-1) {
|
Chris@184
|
40 perror("system call to ps failed");
|
Chris@184
|
41 }
|
Chris@184
|
42 }
|
Chris@184
|
43
|
Chris@184
|
44 void pstats_report()
|
Chris@184
|
45 {
|
Chris@184
|
46 ps_report();
|
Chris@184
|
47 tms_report();
|
Chris@184
|
48 }
|
Chris@184
|
49
|