Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(345)

Unified Diff: third_party/grpc/test/core/profiling/mark_timings.stp

Issue 1932353002: Initial checkin of gRPC to third_party/ Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/grpc/test/core/profiling/mark_timings.stp
diff --git a/third_party/grpc/test/core/profiling/mark_timings.stp b/third_party/grpc/test/core/profiling/mark_timings.stp
new file mode 100644
index 0000000000000000000000000000000000000000..0c0a417faf74370c2b23b0a4bab7695b32e532b1
--- /dev/null
+++ b/third_party/grpc/test/core/profiling/mark_timings.stp
@@ -0,0 +1,40 @@
+/* This script requires a command line argument, to be used in the "process"
+ * probe definition.
+ *
+ * For a statically build binary, that'd be the name of the binary itself.
+ * For dinamically built ones, point to the location of the libgprc.so being
+ * used. */
+
+global starts, times, times_per_tag
+
+probe process(@1).mark("timing_ns_begin") {
+ starts[$arg1, tid()] = gettimeofday_ns();
+}
+
+probe process(@1).mark("timing_ns_end") {
+ tag = $arg1
+ t = gettimeofday_ns();
+ if (s = starts[tag, tid()]) {
+ times[tag, tid()] <<< t-s;
+ delete starts[tag, tid()];
+ }
+}
+
+probe end {
+ printf("%15s %9s %10s %10s %10s %10s\n", "tag", "tid", "count",
+ "min(ns)", "avg(ns)", "max(ns)");
+ foreach ([tag+, tid] in times) {
+ printf("%15X %9d %10d %10d %10d %10d\n", tag, tid, @count(times[tag, tid]),
+ @min(times[tag, tid]), @avg(times[tag, tid]), @max(times[tag, tid]));
+ }
+
+ printf("Per tag average of averages\n");
+ foreach ([tag+, tid] in times) {
+ times_per_tag[tag] <<< @avg(times[tag, tid]);
+ }
+ printf("%15s %10s %10s\n", "tag", "count", "avg(ns)");
+ foreach ([tag+] in times_per_tag) {
+ printf("%15X %10d %10d\n", tag, @count(times_per_tag[tag]),
+ @avg(times_per_tag[tag]));
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698