[added some primitive profiling support
kragen@pobox.com**20070412114811] {
hunk ./bicicleta.ml 19
+let (call_count: (string, int) Hashtbl.t) = Hashtbl.create 100 ;;
+let get_call_count name = try Hashtbl.find call_count name with Not_found -> 0 ;;
hunk ./bicicleta.ml 23
-    | Call(object_, method_name) -> let object_ = eval env object_
+    | Call(object_, method_name) -> 
+        (*Hashtbl.replace call_count method_name (get_call_count method_name + 1) ;
+        *)
+        let object_ = eval env object_
hunk ./bicicleta_repl.ml 1
+(* -*- mode: tuareg; compile-command: "./build" -*- *)
hunk ./bicicleta_repl.ml 6
+
+let call_count_report () =
+  let f key value tail = (value, key) :: tail
+  in let calls_list = Hashtbl.fold f call_count []
+  in (List.fold_left (fun t (v, k) -> t + v) 0 calls_list,
+      List.sort (Pervasives.compare) calls_list) ;;
+
hunk ./bicicleta_repl.ml 28
-  with End_of_file -> output_string outp "\n"
+  with End_of_file -> 
+    let total, per_method = call_count_report ()
+    in List.iter (fun (v, k) -> 
+      output_string outp (k ^ ": " ^ string_of_int v ^ "\n"))
+      (List.rev per_method);
+      output_string outp ("total: " ^ string_of_int total ^ "\n")
hunk ./bicicleta_repl.ml 35
+Hashtbl.clear call_count ;;
}
