/docs/MyDocs

To get this branch, use:
bzr branch http://darksoft.org/webbzr/docs/MyDocs

« back to all changes in this revision

Viewing changes to Analysis/instrumentation/systap/examples/io.stp

  • Committer: Suren A. Chilingaryan
  • Date: 2015-08-21 03:52:00 UTC
  • Revision ID: csa@suren.me-20150821035200-xu1zh22cqlk2omcq
Profiling

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env stap
 
2
# alias_suffixes.stp
 
3
# Uses alias suffixes to track time intervals for a subset of kernel
 
4
# functions. Based on func_time_stats.stp.
 
5
 
 
6
global start, intervals
 
7
 
 
8
# We can apply a suffix to multiple probe points designated by one alias:
 
9
probe miscellany = syscall.open, syscall.close, syscall.read, syscall.write { }
 
10
 
 
11
probe miscellany {
 
12
      start[name, tid()] = gettimeofday_us()
 
13
}
 
14
 
 
15
# The 'return' suffix is passed on to each of the underlying probe points:
 
16
probe miscellany.return {
 
17
      t = gettimeofday_us(); old_t = start[name, tid()]
 
18
      if (old_t) intervals[name] <<< t - old_t
 
19
      delete start[name, tid()]
 
20
}
 
21
 
 
22
probe begin {
 
23
      printf("Collecting data... press Ctrl-C to stop.\n")
 
24
}
 
25
 
 
26
probe end {
 
27
      foreach (name in intervals) {
 
28
              printf("intervals for %s -- min:%dus avg:%dus max:%dus count:%d\n",
 
29
                     name, @min(intervals[name]), @avg(intervals[name]),
 
30
                     @max(intervals[name]), @count(intervals[name]))
 
31
              print(@hist_log(intervals[name]))
 
32
      }
 
33
}