add insert benchmark comparing StringSet to BroTree (StringSet is just a few ms faster for this)
This commit is contained in:
33
bench/conv-words.sml
Normal file
33
bench/conv-words.sml
Normal file
@@ -0,0 +1,33 @@
|
||||
val inIo = TextIO.openIn "words.txt"
|
||||
val outIO = TextIO.openOut "words.sml"
|
||||
|
||||
fun readLines (inIo, acc) =
|
||||
case TextIO.inputLine inIo of
|
||||
SOME word => readLines (inIo, word :: acc)
|
||||
| NONE => List.rev acc
|
||||
|
||||
fun writeLines (outIO, lst) =
|
||||
case lst of
|
||||
[] => ()
|
||||
| word :: tl =>
|
||||
let
|
||||
val word = String.substring (word, 0, String.size word - 2)
|
||||
val isLast = tl = []
|
||||
val word =
|
||||
if isLast then "\"" ^ word ^ "\""
|
||||
else "\"" ^ word ^ "\",\n"
|
||||
val _ = TextIO.output (outIO, word)
|
||||
in
|
||||
writeLines (outIO, tl)
|
||||
end
|
||||
|
||||
fun main () =
|
||||
let
|
||||
val lst = readLines (inIo, [])
|
||||
val _ = TextIO.output
|
||||
(outIO, "structure WordsList = \nstruct \n val words = #[\n")
|
||||
val _ = writeLines (outIO, lst)
|
||||
val _ = TextIO.output (outIO, "]\n end")
|
||||
in
|
||||
()
|
||||
end
|
||||
BIN
bench/insert-bro-tree
Executable file
BIN
bench/insert-bro-tree
Executable file
Binary file not shown.
10
bench/insert-bro-tree.mlb
Normal file
10
bench/insert-bro-tree.mlb
Normal file
@@ -0,0 +1,10 @@
|
||||
$(SML_LIB)/basis/basis.mlb
|
||||
|
||||
ann
|
||||
"allowVectorExps true"
|
||||
in
|
||||
words.sml
|
||||
end
|
||||
|
||||
bro-tree.sml
|
||||
insert-bro-tree.sml
|
||||
11
bench/insert-bro-tree.sml
Normal file
11
bench/insert-bro-tree.sml
Normal file
@@ -0,0 +1,11 @@
|
||||
structure InsertBroTree =
|
||||
struct
|
||||
fun main () =
|
||||
let
|
||||
val endTree = Vector.foldl BroTree.insert BroTree.empty WordsList.words
|
||||
in
|
||||
()
|
||||
end
|
||||
end
|
||||
|
||||
val _ = InsertBroTree.main ()
|
||||
BIN
bench/insert-string-set
Executable file
BIN
bench/insert-string-set
Executable file
Binary file not shown.
10
bench/insert-string-set.mlb
Normal file
10
bench/insert-string-set.mlb
Normal file
@@ -0,0 +1,10 @@
|
||||
$(SML_LIB)/basis/basis.mlb
|
||||
|
||||
ann
|
||||
"allowVectorExps true"
|
||||
in
|
||||
words.sml
|
||||
end
|
||||
|
||||
../src/string-set.sml
|
||||
insert-string-set.sml
|
||||
11
bench/insert-string-set.sml
Normal file
11
bench/insert-string-set.sml
Normal file
@@ -0,0 +1,11 @@
|
||||
structure InsertStringSet =
|
||||
struct
|
||||
fun main () =
|
||||
let
|
||||
val endTrie = Vector.foldl StringSet.insert StringSet.empty WordsList.words
|
||||
in
|
||||
()
|
||||
end
|
||||
end
|
||||
|
||||
val _ = InsertStringSet.main ()
|
||||
58115
bench/words.sml
Normal file
58115
bench/words.sml
Normal file
File diff suppressed because it is too large
Load Diff
58110
bench/words.txt
Normal file
58110
bench/words.txt
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user