Printf.eprintf "Final Mem: %s\n\n\n%!" s2;
r
;;
+
+let pid = ref 0
+let start_perf () =
+
+ let ppid = Unix.getpid() in
+ let cmd = "/usr/bin/perf" in
+ if not (Sys.file_exists cmd) then (failwith "Binary '/usr/bin/perf' not found");
+ let args = [| cmd; "stat"; "--pid=" ^ (string_of_int ppid);
+ "-e"; "L1-dcache-load";
+ "-e"; "L1-dcache-load-misses";
+ "-e"; "L1-dcache-store";
+ "-e"; "L1-dcache-store-misses";
+ "-e"; "L1-icache-load";
+ "-e"; "L1-icache-load-misses";
+ "-e"; "branch-load";
+ "-e"; "branch-load-misses";
+ "-e"; "cpu-cycles";
+ "-e"; "stalled-cycles-frontend";
+ "-e"; "stalled-cycles-backend";
+ "-e"; "instructions";
+ "-e"; "cache-references";
+ "-e"; "cache-misses";
+ "-e"; "branch-instructions";
+ "-e"; "branch-misses";
+ "-e"; "bus-cycles";
+ |] in
+ let p = Unix.fork() in
+ pid := p;
+ if !pid == 0 then Unix.execv cmd args
+
+let stop_perf () =
+ Unix.kill !pid Sys.sigint
+
let time f ?(count=1) ?(msg="") x =
let rec loop i =
Gc.compact();
Gc.space_overhead = 100;
}
-
let mk_runtime run auto doc arg count print outfile =
fun () ->
+ if !Options.do_perf then start_perf ();
let r = time ~count:1 ~msg:"Execution time" (run auto doc) arg in
+ if !Options.do_perf then stop_perf ();
Printf.eprintf "Number of results: %i\n%!" (count r);
match outfile with
None -> ()
let no_jump = ref false
let verbose = ref false
let text_index_type = ref 0
+let do_perf = ref false
(* Only valid if compiled with -DTRACE *)
let trace_file = ref "trace.dot"
"-nj", Arg.Set(no_jump), " disable jumping";
+ "-p", Arg.Set(do_perf), " dump perf counters (Linux only)";
+
"-index-type", Arg.Symbol ([ "default"; "swcsa"; "rlcsa" ],
set_index_type),
" choose text index type";