1/* This script requires a command line argument, to be used in the "process" 2 * probe definition. 3 * 4 * For a statically build binary, that'd be the name of the binary itself. 5 * For dynamically built ones, point to the location of the libgrpc.so being 6 * used. */ 7 8global starts, times, times_per_tag 9 10probe process(@1).mark("timing_ns_begin") { 11 starts[$arg1, tid()] = gettimeofday_ns(); 12} 13 14probe process(@1).mark("timing_ns_end") { 15 tag = $arg1 16 t = gettimeofday_ns(); 17 if (s = starts[tag, tid()]) { 18 times[tag, tid()] <<< t-s; 19 delete starts[tag, tid()]; 20 } 21} 22 23probe end { 24 printf("%15s %9s %10s %10s %10s %10s\n", "tag", "tid", "count", 25 "min(ns)", "avg(ns)", "max(ns)"); 26 foreach ([tag+, tid] in times) { 27 printf("%15X %9d %10d %10d %10d %10d\n", tag, tid, @count(times[tag, tid]), 28 @min(times[tag, tid]), @avg(times[tag, tid]), @max(times[tag, tid])); 29 } 30 31 printf("Per tag average of averages\n"); 32 foreach ([tag+, tid] in times) { 33 times_per_tag[tag] <<< @avg(times[tag, tid]); 34 } 35 printf("%15s %10s %10s\n", "tag", "count", "avg(ns)"); 36 foreach ([tag+] in times_per_tag) { 37 printf("%15X %10d %10d\n", tag, @count(times_per_tag[tag]), 38 @avg(times_per_tag[tag])); 39 } 40} 41