add benchmarks for tiny_rope in bench folder

This commit is contained in:
2024-05-28 08:01:10 +01:00
parent 9728a1ca25
commit 1f3736e690
18 changed files with 585 additions and 49 deletions

View File

@@ -1,8 +1,5 @@
bench: gap_buffer_svelte gap_buffer_rust gap_buffer_seph gap_buffer_automerge
./gap_buffer_svelte
./gap_buffer_rust
./gap_buffer_seph
./gap_buffer_automerge
bench: gap_buffer_svelte gap_buffer_rust gap_buffer_seph gap_buffer_automerge rope_svelte rope_rust rope_seph rope_automerge
hyperfine './gap_buffer_svelte' './rope_svelte' './gap_buffer_rust' './rope_rust' './gap_buffer_seph' './rope_seph' './gap_buffer_automerge' './rope_automerge' --export-markdown benchmarks.md
gap_buffer_svelte:
mlton gap_buffer_svelte.mlb
@@ -16,5 +13,17 @@ gap_buffer_seph:
gap_buffer_automerge:
mlton gap_buffer_automerge.mlb
rope_svelte:
mlton rope_svelte.mlb
rope_rust:
mlton rope_rust.mlb
rope_seph:
mlton rope_seph.mlb
rope_automerge:
mlton rope_automerge.mlb
clean:
rm -f gap_buffer_svelte gap_buffer_rust gap_buffer_seph gap_buffer_automerge
rm -f gap_buffer_svelte gap_buffer_rust gap_buffer_seph gap_buffer_automerge rope_svelte rope_rust rope_seph rope_automerge

4
bench/benchmarks.md Normal file
View File

@@ -0,0 +1,4 @@
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|:---|---:|---:|---:|---:|
| `./gap_buffer_svelte` | 15.9 ± 7.4 | 4.9 | 34.2 | 1.00 |
| `./rope_svelte` | 20.5 ± 9.9 | 8.5 | 39.3 | 1.29 ± 0.87 |

View File

@@ -5,8 +5,6 @@ struct
val insert = GapBuffer.insert
val delete = GapBuffer.delete
val toString = GapBuffer.toString
val title = "Automerge"
val txns = AutomergePaper.txns
end

View File

@@ -5,8 +5,6 @@ struct
val insert = GapBuffer.insert
val delete = GapBuffer.delete
val toString = GapBuffer.toString
val title = "Rust"
val txns = RustCode.txns
end

View File

@@ -5,8 +5,6 @@ struct
val insert = GapBuffer.insert
val delete = GapBuffer.delete
val toString = GapBuffer.toString
val title = "Seph"
val txns = SephBlog.txns
end

View File

@@ -5,8 +5,6 @@ struct
val insert = GapBuffer.insert
val delete = GapBuffer.delete
val toString = GapBuffer.toString
val title = "Svelte"
val txns = SvelteComponent.txns
end

13
bench/rope_automerge.mlb Normal file
View File

@@ -0,0 +1,13 @@
$(SML_LIB)/basis/basis.mlb
ann
"allowVectorExps true"
in
automerge.sml
end
transaction.sml
run.sml
../src/tiny_rope.sml
rope_automerge.sml

13
bench/rope_automerge.sml Normal file
View File

@@ -0,0 +1,13 @@
structure RopeAutomerge: TRANSACTION =
struct
type t = TinyRope.t
val empty = TinyRope.empty
val insert = TinyRope.insert
val delete = TinyRope.delete
val toString = TinyRope.toString
val txns = AutomergePaper.txns
end
structure Main = Run(RopeAutomerge)
val _ = Main.run ()

13
bench/rope_rust.mlb Normal file
View File

@@ -0,0 +1,13 @@
$(SML_LIB)/basis/basis.mlb
ann
"allowVectorExps true"
in
rust.sml
end
transaction.sml
run.sml
../src/tiny_rope.sml
rope_rust.sml

13
bench/rope_rust.sml Normal file
View File

@@ -0,0 +1,13 @@
structure RopeRust: TRANSACTION =
struct
type t = TinyRope.t
val empty = TinyRope.empty
val insert = TinyRope.insert
val delete = TinyRope.delete
val toString = TinyRope.toString
val txns = RustCode.txns
end
structure Main = Run(RopeRust)
val _ = Main.run ()

13
bench/rope_seph.mlb Normal file
View File

@@ -0,0 +1,13 @@
$(SML_LIB)/basis/basis.mlb
ann
"allowVectorExps true"
in
seph.sml
end
transaction.sml
run.sml
../src/tiny_rope.sml
rope_seph.sml

13
bench/rope_seph.sml Normal file
View File

@@ -0,0 +1,13 @@
structure RopeSeph: TRANSACTION =
struct
type t = TinyRope.t
val empty = TinyRope.empty
val insert = TinyRope.insert
val delete = TinyRope.delete
val toString = TinyRope.toString
val txns = SephBlog.txns
end
structure Main = Run(RopeSeph)
val _ = Main.run ()

13
bench/rope_svelte.mlb Normal file
View File

@@ -0,0 +1,13 @@
$(SML_LIB)/basis/basis.mlb
ann
"allowVectorExps true"
in
svelte.sml
end
transaction.sml
run.sml
../src/tiny_rope.sml
rope_svelte.sml

13
bench/rope_svelte.sml Normal file
View File

@@ -0,0 +1,13 @@
structure RopeSvelte: TRANSACTION =
struct
type t = TinyRope.t
val empty = TinyRope.empty
val insert = TinyRope.insert
val delete = TinyRope.delete
val toString = TinyRope.toString
val txns = SvelteComponent.txns
end
structure Main = Run(RopeSvelte)
val _ = Main.run ()

View File

@@ -14,40 +14,9 @@ struct
Vector.foldl folder Txn.empty Txn.txns
end
fun runTxnsTime () =
let
val startTime = Time.now ()
val startTime = Time.toMilliseconds startTime
val x = runTxns ()
val endTime = Time.now ()
val endTime = Time.toMilliseconds endTime
val timeDiff = endTime - startTime
val timeDiff = LargeInt.toString timeDiff
val timeTook = String.concat [timeDiff, " ms taken for " ^ Txn.title ^ " txns\n"]
val _ = (print timeTook)
in
x
end
fun write (fileName, buffer) =
let
val str = Txn.toString buffer
val io = TextIO.openOut fileName
val _ = TextIO.output (io, str)
val _ = TextIO.closeOut io
in
()
end
fun run () =
let
val buffer = runTxnsTime ()
(* The write operation guarantees that MLton doesn't optimise away the
* buffer's contents, because it has to write the contents to a file. *)
val _ = write ("out/" ^ Txn.title ^ ".txt", buffer)
val buffer = runTxns ()
in
()
end

View File

@@ -5,7 +5,5 @@ sig
val insert: int * string * t -> t
val delete: int * int * t -> t
val toString: t -> string
val title : string
val txns : (int * int * string) vector
end