commit bench folder (also committing examples folder but that's kind of broken at this state)

This commit is contained in:
2024-05-27 13:30:53 +01:00
parent b5c70772fa
commit d6a5055be1
23 changed files with 459773 additions and 10 deletions

20
bench/Makefile Normal file
View File

@@ -0,0 +1,20 @@
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
gap_buffer_svelte:
mlton gap_buffer_svelte.mlb
gap_buffer_rust:
mlton gap_buffer_rust.mlb
gap_buffer_seph:
mlton gap_buffer_seph.mlb
gap_buffer_automerge:
mlton gap_buffer_automerge.mlb
clean:
rm -f gap_buffer_svelte gap_buffer_rust gap_buffer_svelte gap_buffer_automerge

259783
bench/automerge.sml Normal file

File diff suppressed because it is too large Load Diff

17
bench/bench.mlb Normal file
View File

@@ -0,0 +1,17 @@
$(SML_LIB)/basis/basis.mlb
ann
"allowVectorExps true"
in
svelte.sml
rust.sml
seph.sml
automerge.sml
end
../tiny_rope.sml
../rope.sml
../gap_buffer.sml
utils.sml

BIN
bench/gap_buffer_automerge Executable file

Binary file not shown.

View File

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

View File

@@ -0,0 +1,15 @@
structure GapBufferAutomerge: TRANSACTION =
struct
type t = GapBuffer.t
val empty = GapBuffer.empty
val insert = GapBuffer.insert
val delete = GapBuffer.delete
val toString = GapBuffer.toString
val title = "Automerge"
val txns = AutomergePaper.txns
end
structure Main = Run(GapBufferAutomerge)
val _ = Main.run ()

BIN
bench/gap_buffer_rust Executable file

Binary file not shown.

13
bench/gap_buffer_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/gap_buffer.sml
gap_buffer_rust.sml

15
bench/gap_buffer_rust.sml Normal file
View File

@@ -0,0 +1,15 @@
structure GapBufferRust: TRANSACTION =
struct
type t = GapBuffer.t
val empty = GapBuffer.empty
val insert = GapBuffer.insert
val delete = GapBuffer.delete
val toString = GapBuffer.toString
val title = "Rust"
val txns = RustCode.txns
end
structure Main = Run(GapBufferRust)
val _ = Main.run ()

BIN
bench/gap_buffer_seph Executable file

Binary file not shown.

13
bench/gap_buffer_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/gap_buffer.sml
gap_buffer_seph.sml

15
bench/gap_buffer_seph.sml Normal file
View File

@@ -0,0 +1,15 @@
structure GapBufferSeph: TRANSACTION =
struct
type t = GapBuffer.t
val empty = GapBuffer.empty
val insert = GapBuffer.insert
val delete = GapBuffer.delete
val toString = GapBuffer.toString
val title = "Seph"
val txns = SephBlog.txns
end
structure Main = Run(GapBufferSeph)
val _ = Main.run ()

BIN
bench/gap_buffer_svelte Executable file

Binary file not shown.

View File

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

View File

@@ -0,0 +1,15 @@
structure GapBufferSvelete: TRANSACTION =
struct
type t = GapBuffer.t
val empty = GapBuffer.empty
val insert = GapBuffer.insert
val delete = GapBuffer.delete
val toString = GapBuffer.toString
val title = "Svelte"
val txns = SvelteComponent.txns
end
structure Main = Run(GapBufferSvelete)
val _ = Main.run ()

54
bench/run.sml Normal file
View File

@@ -0,0 +1,54 @@
functor Run(Txn: TRANSACTION) =
struct
local
fun folder ((pos, delNum, insStr), buffer) =
let
val buffer =
if delNum > 0 then Txn.delete (pos, delNum, buffer) else buffer
in
if String.size insStr > 0 then Txn.insert (pos, insStr, buffer)
else buffer
end
in
fun runTxns () =
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)
in
()
end
end

41081
bench/rust.sml Normal file

File diff suppressed because one or more lines are too long

138556
bench/seph.sml Normal file

File diff suppressed because one or more lines are too long

19994
bench/svelte.sml Normal file

File diff suppressed because one or more lines are too long

11
bench/transaction.sml Normal file
View File

@@ -0,0 +1,11 @@
signature TRANSACTION =
sig
type t
val empty: t
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