(* test throughput of network connection to sctl *) module HT = Hashtbl open Sctl let printlocals (pc:int64) (lt:loctab) : unit = let (_, locres) = Hashtbl.find lt pc in let printloc (l:sctlloc) = let kn = (match l.sl_kind with L_param -> "param" | L_var -> "local var") in ignore (Printf.fprintf stderr "%s %s %s %s\n" kn (formattype l.sl_type) l.sl_id (format_lexpr l.sl_lexpr)) in List.iter printloc locres let nstest () = let sns = ns "/home/jdraper/projects/l1/l1" in let mainsym = looksym sns "main" in ignore (Printf.fprintf stderr "%s\n" (formatsym mainsym)); let st = enumsym sns in let slist = ref [] in HT.iter (fun k v -> slist := v::!slist) st; let cf (s1:sym) (s2:sym) = if Int64.compare s1.s_val 0L < 0 then if Int64.compare s2.s_val 0L < 0 then Int64.compare s1.s_val s2.s_val else 1 else if Int64.compare s2.s_val 0L < 0 then -1 else Int64.compare s1.s_val s2.s_val in let sortedsyms = List.sort cf !slist in List.iter (fun v -> ignore (Printf.fprintf stderr "%s\n" (formatsym v))) sortedsyms; let mainctx = { empty_ctx with rip=mainsym.s_val; } in ignore (Printf.fprintf stderr "Locals for main:\n"); let lt = enumloc sns mainctx in printlocals mainctx.rip lt; let mainctx = { empty_ctx with rip=Int64.add mainsym.s_val 1L; } in ignore (Printf.fprintf stderr "Locals for main+1:\n"); let lt = enumloc sns mainctx in printlocals mainctx.rip lt; let mainctx = { empty_ctx with rip=Int64.add mainsym.s_val 2L; } in ignore (Printf.fprintf stderr "Locals for main+2:\n"); let lt = enumloc sns mainctx in printlocals mainctx.rip lt; let mainctx = { empty_ctx with rip=Int64.add mainsym.s_val 1032L; } in ignore (Printf.fprintf stderr "Locals for main+1032:\n"); let lt = enumloc sns mainctx in printlocals mainctx.rip lt; flush_all (); close sns.ns_sctl; ;; nstest ()