Merge branch 'local-ocamlbuild' into local-trunk
[SXSI/xpathcomp.git] / src / profile.ml
diff --git a/src/profile.ml b/src/profile.ml
new file mode 100644 (file)
index 0000000..c43dda6
--- /dev/null
@@ -0,0 +1,11 @@
+let table = Hashtbl.create 103
+
+let summary fmt =
+  Hashtbl.iter (fun (m, f) d  ->
+    let c, tl = !d in
+    let tspent =
+      List.fold_left (fun acc e -> e +. acc) 0. tl 
+    in
+    Format.fprintf fmt "%s: %s = called %i times, total: %fms, average: %fms\n"
+      m f c tspent (tspent /. (float_of_int c))) table;
+  Format.fprintf fmt "%!"