File: fntimes.stp

package info (click to toggle)
systemtap 3.1-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 32,860 kB
  • ctags: 12,513
  • sloc: cpp: 58,610; ansic: 58,189; exp: 37,322; sh: 10,633; xml: 7,771; perl: 2,252; python: 2,066; tcl: 1,305; makefile: 969; lisp: 105; java: 100; awk: 94; asm: 91; sed: 16
file content (23 lines) | stat: -rwxr-xr-x 875 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#! /usr/bin/env stap

# usage:   fntimes.stp FUNCTIONPROBE
# e.g.     fntimes.stp 'module("ext4").function("*")'

global mincount = 100      # training: beneath this number of hits, only collect data
global note_percent = 250  # percent beyond maximum-so-far to generate report for
function time() { return gettimeofday_us() }    # time measurement function

global times

function check(t)   # t: elapsed time
{
   if (@count(times[ppfunc()]) >= mincount
       && t >= @max(times[ppfunc()]) * note_percent / 100) {   # also consider @avg()
     printf("function %s well over %s time (%d vs %d), duration variance %d s^2\n",
            ppfunc(), "maximum", t, @max(times[ppfunc()]), @variance(times[ppfunc()], 3))
     # also consider: print_backtrace()
   }
   times[ppfunc()] <<< t  # (increments @count, updates @max)
}

probe $1.return { check(time()-@entry(time())) }