change utils.sml to run using rope (with line metadata) instead of tiny_rope, and verify that line metadata is correct
This commit is contained in:
83
utils.sml
83
utils.sml
@@ -1,13 +1,13 @@
|
||||
fun time_func title f =
|
||||
let
|
||||
val title = String.concat ["Starting " , title , "..."]
|
||||
val title = String.concat ["Starting ", title, "..."]
|
||||
val _ = (print title)
|
||||
val start_time = Time.now()
|
||||
val start_time = Time.now ()
|
||||
val start_time = Time.toNanoseconds start_time
|
||||
val x = f()
|
||||
val end_time = Time.now()
|
||||
val x = f ()
|
||||
val end_time = Time.now ()
|
||||
val end_time = Time.toNanoseconds end_time
|
||||
val time_diff = end_time - start_time
|
||||
val time_diff = end_time - start_time
|
||||
val time_diff = LargeInt.toString time_diff
|
||||
val time_took = String.concat ["took ", time_diff, " nanoseconds\n"]
|
||||
val _ = (print time_took)
|
||||
@@ -16,38 +16,28 @@ fun time_func title f =
|
||||
end
|
||||
|
||||
fun run_txns arr =
|
||||
Vector.foldl
|
||||
Vector.foldl
|
||||
(fn ((pos, del_num, ins_str), rope) =>
|
||||
let
|
||||
val rope =
|
||||
if del_num > 0
|
||||
then TinyRope.delete(pos, del_num, rope)
|
||||
else rope
|
||||
val str_size = String.size ins_str
|
||||
val rope =
|
||||
if str_size > 0
|
||||
then TinyRope.insert(pos, ins_str, rope)
|
||||
else rope
|
||||
in
|
||||
rope
|
||||
end)
|
||||
TinyRope.empty arr
|
||||
let
|
||||
val rope =
|
||||
if del_num > 0 then Rope.delete (pos, del_num, rope) else rope
|
||||
val str_size = String.size ins_str
|
||||
val rope =
|
||||
if str_size > 0 then Rope.insert (pos, ins_str, rope) else rope
|
||||
in
|
||||
rope
|
||||
end) Rope.empty arr
|
||||
|
||||
fun run_txns_time title arr =
|
||||
let
|
||||
val f = (fn () => run_txns arr)
|
||||
in
|
||||
time_func title f
|
||||
fun run_txns_time title arr =
|
||||
let val f = (fn () => run_txns arr)
|
||||
in time_func title f
|
||||
end
|
||||
|
||||
fun run_to_string rope =
|
||||
TinyRope.toString rope
|
||||
fun run_to_string rope = Rope.toString rope
|
||||
|
||||
fun run_to_string_time title rope =
|
||||
let
|
||||
val f = (fn () => run_to_string rope)
|
||||
in
|
||||
time_func title f
|
||||
let val f = (fn () => run_to_string rope)
|
||||
in time_func title f
|
||||
end
|
||||
|
||||
fun run_txns_1000_times (counter, arr, total) =
|
||||
@@ -61,14 +51,14 @@ fun run_txns_1000_times (counter, arr, total) =
|
||||
end
|
||||
else
|
||||
let
|
||||
val start_time = Time.now()
|
||||
val start_time = Time.now ()
|
||||
val start_time = Time.toNanoseconds start_time
|
||||
|
||||
val _ = run_txns arr
|
||||
|
||||
val end_time = Time.now()
|
||||
val end_time = Time.now ()
|
||||
val end_time = Time.toNanoseconds end_time
|
||||
val time_diff = end_time - start_time
|
||||
val time_diff = end_time - start_time
|
||||
val counter = counter + 1
|
||||
val total = time_diff + total
|
||||
in
|
||||
@@ -76,7 +66,7 @@ fun run_txns_1000_times (counter, arr, total) =
|
||||
end
|
||||
|
||||
fun write_file filename acc =
|
||||
let
|
||||
let
|
||||
val str = String.concatWith "," acc
|
||||
val fd = TextIO.openOut filename
|
||||
val _ = TextIO.output (fd, str) handle e => (TextIO.closeOut fd; raise e)
|
||||
@@ -85,16 +75,29 @@ fun write_file filename acc =
|
||||
()
|
||||
end
|
||||
|
||||
val _ =
|
||||
fun main () =
|
||||
let
|
||||
(* Timing benchmarks. *)
|
||||
val start_time = LargeInt.fromInt 0
|
||||
val svelte = run_txns_1000_times (999 ,svelte_arr, start_time )
|
||||
val _ = run_txns_1000_times (999, svelte_arr, start_time)
|
||||
val _ = run_txns_1000_times (999, rust_arr, start_time)
|
||||
val _ = run_txns_1000_times (999, seph_arr, start_time)
|
||||
val _ = run_txns_1000_times (999, automerge_arr, start_time)
|
||||
|
||||
val rust = run_txns_1000_times (999 ,rust_arr, start_time )
|
||||
(* Tests that line metadata is correct; will fail if incorrect. *)
|
||||
val svelte = run_txns svelte_arr
|
||||
val _ = Rope.verifyLines svelte
|
||||
|
||||
val seph = run_txns_1000_times (999, seph_arr, start_time)
|
||||
val rust = run_txns rust_arr
|
||||
val _ = Rope.verifyLines rust
|
||||
|
||||
val automerge = run_txns_1000_times (999, automerge_arr , start_time)
|
||||
val seph = run_txns seph_arr
|
||||
val _ = Rope.verifyLines seph
|
||||
|
||||
val automerge = run_txns automerge_arr
|
||||
val _ = Rope.verifyLines automerge
|
||||
in
|
||||
()
|
||||
end
|
||||
|
||||
val _ = main ()
|
||||
|
||||
Reference in New Issue
Block a user