summaryrefslogtreecommitdiffstats
path: root/translate.cxx
diff options
context:
space:
mode:
authorwcohen <wcohen>2006-05-02 19:26:34 +0000
committerwcohen <wcohen>2006-05-02 19:26:34 +0000
commit4b17d6af571193c8a78c470ef941bbfea73de253 (patch)
tree9ac3ac53f04b20469b7765c532336f431bac067a /translate.cxx
parent86cae39ac23bb8fd44416520b53b8fc74ae9a857 (diff)
downloadsystemtap-steved-4b17d6af571193c8a78c470ef941bbfea73de253.tar.gz
systemtap-steved-4b17d6af571193c8a78c470ef941bbfea73de253.tar.xz
systemtap-steved-4b17d6af571193c8a78c470ef941bbfea73de253.zip
"-t" option to collect information the number of times a probe runs and
the average amount of time spent in the probe.
Diffstat (limited to 'translate.cxx')
-rw-r--r--translate.cxx32
1 files changed, 32 insertions, 0 deletions
diff --git a/translate.cxx b/translate.cxx
index b4c54a8d..e9a297e7 100644
--- a/translate.cxx
+++ b/translate.cxx
@@ -895,6 +895,14 @@ c_unparser::emit_common_header ()
if (!session->stat_decls.empty())
o->newline() << "#include \"stat.c\"\n";
+
+ // XXX: Cannot tell if statistics are being used for the timing collection.
+ o->newline();
+ o->newline() << "#ifdef STP_TIMING";
+ o->newline() << "#include \"stat.c\"";
+ o->newline() << "#include \"arith.c\"";
+ o->newline() << "#endif";
+
}
@@ -1006,6 +1014,18 @@ c_unparser::emit_module_init ()
o->newline() << "noinline void unregister_probe_" << i << " (void) {";
o->indent(1);
session->probes[i]->emit_deregistrations (o);
+ o->newline() << "#ifdef STP_TIMING";
+ o->newline(1) << "{";
+ o->newline() << "struct stat_data *stats = _stp_stat_get (time_"
+ << session->probes[i]->name << ", 0);";
+ o->newline() << "int64_t avg = 0;";
+ o->newline() << "const char *error;";
+ o->newline() << "if (stats->count) avg = _stp_div64(&error, stats->sum, stats->count);";
+ o->newline() << "_stp_printf (\"time_" << session->probes[i]->name
+ << " %lld@%lld\\n\"," << "stats->count, avg);";
+ o->newline() << "_stp_print_flush();";
+ o->newline() << "#endif";
+ o->newline(-1) << "}";
o->newline(-1) << "}";
}
@@ -1040,6 +1060,15 @@ c_unparser::emit_module_init ()
o->newline() << "rwlock_init (& global_" << c_varname (v->name) << "_lock);";
}
+ // initialize each Stat used for timing information
+ o->newline() << "#ifdef STP_TIMING";
+ for (unsigned i=0; i<session->probes.size(); i++)
+ {
+ o->newline() << "time_" << session->probes[i]->name
+ << " = _stp_stat_init (HIST_NONE);";
+ }
+ o->newline() << "#endif";
+
for (unsigned i=0; i<session->probes.size(); i++)
{
o->newline() << "rc = register_probe_" << i << "();";
@@ -3802,6 +3831,9 @@ translate_pass (systemtap_session& s)
if (s.bulk_mode)
s.op->newline() << "#define STP_RELAYFS";
+ if (s.timing)
+ s.op->newline() << "#define STP_TIMING" << " " << s.timing ;
+
s.op->newline() << "#include \"runtime.h\"";
s.op->newline() << "#include \"current.c\"";
s.op->newline() << "#include \"stack.c\"";