$ ./t1
#!/bin/sh
cat t1
echo -----
cat hello.c
gcc -pg hello.c
echo -----
wc *.c
echo -----
./a.out *.c
echo -----
gprof a.out gmon.out | head
echo -----
-----
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
void processline ( char *line ) {
}
void doit ( char *filename ) {
FILE *fp;
if ( (fp=fopen(filename,"r")) != NULL ) {
char buff[BUFSIZ];
int lines = 0;
while ( fgets( buff, BUFSIZ, fp ) != NULL ) {
processline(buff);
lines++;
}
printf( "%d %s\n", lines, filename );
fclose( fp );
}
}
int main ( int argc, char *argv[] ) {
while ( --argc ) doit( *(++argv) );
return 0;
}
-----
174 731 4297 board.c
158 667 4891 cli_ser_pipes.c
82 355 2295 file-r-rb.c
1 2 19 float.c
51 219 1564 hello-back.c
25 77 522 hello.c
75 256 1481 hello-old.c
1 8 27 null.c
59 249 1519 num2words.c
16 45 261 rdtsc.c
22 69 362 realloc.c
41 172 1096 roman.c
85 365 2369 rosette.c
290 1272 7634 speed-read.c
1080 4487 28337 total
-----
174 board.c
158 cli_ser_pipes.c
82 file-r-rb.c
1 float.c
51 hello-back.c
25 hello.c
75 hello-old.c
1 null.c
59 num2words.c
16 rdtsc.c
22 realloc.c
41 roman.c
85 rosette.c
290 speed-read.c
-----
Flat profile:
Each sample counts as 0.00195312 seconds.
no time accumulated
% cumulative self self total
time seconds seconds calls Ts/call Ts/call name
0.00 0.00 0.00 1080 0.00 0.00 processline
0.00 0.00 0.00 14 0.00 0.00 doit
-----