X-Git-Url: http://nitlanguage.org diff --git a/benchmarks/bench_strings.sh b/benchmarks/bench_strings.sh index c327d58..0bb13a7 100755 --- a/benchmarks/bench_strings.sh +++ b/benchmarks/bench_strings.sh @@ -54,7 +54,7 @@ function bench_array() echo "*** Benching Array.to_s performance ***" fi - ../bin/nitg --global ./strings/array_tos.nit -m ./strings/array_to_s_vars/array_to_s_rope.nit --make-flags "CFLAGS=\"-g -O2 -DNOBOEHM\"" + ../bin/nitg --global ./strings/array_tos.nit -m ./strings/array_to_s_vars/array_to_s_flatstr.nit -m ../lib/standard/ropes.nit --make-flags "CFLAGS=\"-g -O2 -DNOBOEHM\"" prepare_res arr_tos_ropes.out arr_tos_ropes ropes if $verbose; then @@ -67,6 +67,19 @@ function bench_array() bench_command $i ropes$i ./array_tos --loops $2 --strlen $i --ccts $1 "NIT_GC_CHOOSER=large" done + ../bin/nitg --global ./strings/array_tos.nit -m ./strings/array_to_s_vars/array_to_s_flatstr.nit -m ../lib/standard/ropes.nit -m ../lib/buffered_ropes.nit --make-flags "CFLAGS=\"-g -O2 -DNOBOEHM\"" + + prepare_res arr_tos_buf_ropes.out arr_tos_buf_ropes buffered_ropes + if $verbose; then + echo "Buffered Ropes :" + fi + for i in `seq 1 "$3"`; do + if $verbose; then + echo "String length = $i, Concats/loop = $1, Loops = $2" + fi + bench_command $i buf_ropes$i ./array_tos --loops $2 --strlen $i --ccts $1 "NIT_GC_CHOOSER=large" + done + ../bin/nitg --global ./strings/array_tos.nit -m ./strings/array_to_s_vars/array_to_s_flatstr.nit --make-flags "CFLAGS=\"-g -O2 -DNOBOEHM\"" prepare_res arr_tos_flat.out arr_tos_flat flatstring @@ -110,7 +123,7 @@ function bench_array() prepare_res arr_tos_man_buf.out arr_tos_man_buf flatbuf_with_capacity if $verbose; then - echo "Memmove :" + echo "FlatBuffer.with_capacity :" fi for i in `seq 1 "$3"`; do if $verbose; then @@ -119,25 +132,30 @@ function bench_array() bench_command $i flatbuf_with_capacity$i ./array_tos --loops $2 --strlen $i --ccts $1 "NIT_GC_CHOOSER=large" done + ../bin/nitg --global ./strings/array_tos.nit -m ./strings/array_to_s_vars/array_to_s_rope_buf.nit --make-flags "CFLAGS=\"-g -O2 -DNOBOEHM\"" + + prepare_res arr_tos_rope_buf.out arr_tos_rope_buf ropebuf + if $verbose; then + echo "RopeBuffer :" + fi + for i in `seq 1 "$3"`; do + if $verbose; then + echo "String length = $i, Concats/loop = $1, Loops = $2" + fi + bench_command $i ropebuf$i ./array_tos --loops $2 --strlen $i --ccts $1 "NIT_GC_CHOOSER=large" + done + plot array_tos.gnu } function bench_concat() { - if $verbose; then - echo "*** Benching concat performance ***" - fi + ../bin/nitg --global ./strings/chain_concat.nit --make-flags "CFLAGS=\"-g -O2 -DNOBOEHM\"" + ../bin/nitg --global ./strings/utf_chain_concat.nit --make-flags "CFLAGS=\"-g -O2 -DNOBOEHM\"" - prepare_res concat_ropes.out concat_ropes ropes if $verbose; then - echo "Ropes :" + echo "*** Benching concat performance ***" fi - for i in `seq 1 "$1"`; do - if $verbose; then - echo "String length = $i, Concats/loop = $2, Loops = $3" - fi - bench_command $i ropes$i ./chain_concat -m rope --loops $2 --strlen $3 --ccts $i "NIT_GC_CHOOSER=large" - done prepare_res concat_flat.out concat_flat flatstring if $verbose; then @@ -172,37 +190,57 @@ function bench_concat() bench_command $i flatstr_utf8_noindex$i ./utf_chain_concat -m flatstr_utf8_noindex --loops $2 --strlen $3 --ccts $i "NIT_GC_CHOOSER=large" done - plot concat.gnu -} + ../bin/nitg --global ./strings/chain_concat.nit -m ../lib/standard/ropes.nit --make-flags "CFLAGS=\"-g -O2 -DNOBOEHM\"" -function bench_iteration() -{ + prepare_res concat_ropes.out concat_ropes ropes if $verbose; then - echo "*** Benching iteration performance ***" + echo "Ropes :" fi + for i in `seq 1 "$1"`; do + if $verbose; then + echo "String length = $i, Concats/loop = $2, Loops = $3" + fi + bench_command $i ropes$i ./chain_concat -m flatstr --loops $2 --strlen $3 --ccts $i "NIT_GC_CHOOSER=large" + done - prepare_res iter_ropes_iter.out iter_ropes_iter ropes_iter + ../bin/nitg --global ./strings/chain_concat.nit -m ../lib/standard/ropes.nit -m ../lib/buffered_ropes.nit --make-flags "CFLAGS=\"-g -O2 -DNOBOEHM\"" + + prepare_res concat_buf_ropes.out concat_buf_ropes buffered_ropes if $verbose; then - echo "Ropes by iterator :" + echo "buffered ropes :" fi for i in `seq 1 "$1"`; do if $verbose; then - echo "String base length = $1, Concats (depth of the rope) = $i, Loops = $3" + echo "string length = $i, concats/loop = $2, loops = $3" fi - bench_command $i ropes_iter$i ./iteration_bench -m rope --iter-mode iterator --loops $2 --strlen $3 --ccts $i "NIT_GC_CHOOSER=large" + bench_command $i buf_ropes$i ./chain_concat -m flatstr --loops $2 --strlen $3 --ccts $i "NIT_GC_CHOOSER=large" done - prepare_res iter_ropes_index.out iter_ropes_index ropes_index + ../bin/nitg --global ./strings/chain_cct_ropebuf.nit --make-flags "CFLAGS=\"-g -O2 -DNOBOEHM\"" + + prepare_res cct_buf_ropes.out cct_buf_ropes cctbuf_ropes if $verbose; then - echo "Ropes by index :" + echo "buffered ropes :" fi for i in `seq 1 "$1"`; do if $verbose; then - echo "String base length = $1, Concats (depth of the rope) = $i, Loops = $3" + echo "string length = $i, concats/loop = $2, loops = $3" fi - bench_command $i ropes_index$i ./iteration_bench -m rope --iter-mode index --loops $2 --strlen $3 --ccts $i "NIT_GC_CHOOSER=large" + bench_command $i cctbuf_ropes$i ./chain_cct_ropebuf --loops $2 --strlen $3 --ccts $i "NIT_GC_CHOOSER=large" done + plot concat.gnu +} + +function bench_iteration() +{ + if $verbose; then + echo "*** Benching iteration performance ***" + fi + + ../bin/nitg --global ./strings/iteration_bench.nit --make-flags "CFLAGS=\"-g -O2 -DNOBOEHM\"" + ../bin/nitg --global ./strings/utf_iteration_bench.nit --make-flags "CFLAGS=\"-g -O2 -DNOBOEHM\"" + prepare_res iter_flat_iter.out iter_flat_iter flatstring_iter if $verbose; then echo "FlatStrings by iterator :" @@ -269,26 +307,66 @@ function bench_iteration() bench_command $i flatstr_index_utf8_noindex$i ./utf_iteration_bench -m flatstr_utf8_noindex --iter-mode index --loops $2 --strlen $3 --ccts $i "NIT_GC_CHOOSER=large" done - plot iter.gnu -} + ../bin/nitg --global ./strings/iteration_bench.nit -m ../lib/standard/ropes.nit --make-flags "CFLAGS=\"-g -O2 -DNOBOEHM\"" -function bench_substr() -{ + prepare_res iter_ropes_iter.out iter_ropes_iter ropes_iter if $verbose; then - echo "*** Benching substring performance ***" + echo "Ropes by iterator :" fi + for i in `seq 1 "$1"`; do + if $verbose; then + echo "String base length = $1, Concats (depth of the rope) = $i, Loops = $3" + fi + bench_command $i ropes_iter$i ./iteration_bench -m flatstr --iter-mode iterator --loops $2 --strlen $3 --ccts $i "NIT_GC_CHOOSER=large" + done - prepare_res substr_ropes.out substr_ropes ropes + prepare_res iter_ropes_index.out iter_ropes_index ropes_index if $verbose; then - echo "Ropes :" + echo "Ropes by index :" fi for i in `seq 1 "$1"`; do if $verbose; then - echo "String length = $i, loops = $2, Loops = $3" + echo "String base length = $1, Concats (depth of the rope) = $i, Loops = $3" + fi + bench_command $i ropes_index$i ./iteration_bench -m flatstr --iter-mode index --loops $2 --strlen $3 --ccts $i "NIT_GC_CHOOSER=large" + done + + ../bin/nitg --global ./strings/iteration_bench.nit -m ../lib/standard/ropes.nit -m ../lib/buffered_ropes.nit --make-flags "CFLAGS=\"-g -O2 -DNOBOEHM\"" + + prepare_res iter_buf_ropes_iter.out iter_buf_ropes_iter buf_ropes_iter + if $verbose; then + echo "Buffered Ropes by iterator :" + fi + for i in `seq 1 "$1"`; do + if $verbose; then + echo "String base length = $1, Concats (depth of the rope) = $i, Loops = $3" + fi + bench_command $i buf_ropes_iter$i ./iteration_bench -m flatstr --iter-mode iterator --loops $2 --strlen $3 --ccts $i "NIT_GC_CHOOSER=large" + done + + prepare_res iter_buf_ropes_index.out iter_buf_ropes_index buf_ropes_index + if $verbose; then + echo "Buffered Ropes by index :" + fi + for i in `seq 1 "$1"`; do + if $verbose; then + echo "String base length = $1, Concats (depth of the rope) = $i, Loops = $3" fi - bench_command $i ropes$i ./substr_bench -m rope --loops $2 --strlen $3 --ccts $i "NIT_GC_CHOOSER=large" + bench_command $i buf_ropes_index$i ./iteration_bench -m flatstr --iter-mode index --loops $2 --strlen $3 --ccts $i "NIT_GC_CHOOSER=large" done + plot iter.gnu +} + +function bench_substr() +{ + if $verbose; then + echo "*** Benching substring performance ***" + fi + + ../bin/nitg --global ./strings/substr_bench.nit --make-flags "CFLAGS=\"-g -O2 -DNOBOEHM\"" + ../bin/nitg --global ./strings/utf_substr_bench.nit --make-flags "CFLAGS=\"-g -O2 -DNOBOEHM\"" + prepare_res substr_flat.out substr_flat flatstring if $verbose; then echo "FlatStrings :" @@ -322,6 +400,31 @@ function bench_substr() bench_command $i flatstring_utf8_noindex$i ./utf_substr_bench -m flatstr_utf8_noindex --loops $2 --strlen $3 --ccts $i "NIT_GC_CHOOSER=large" done + ../bin/nitg --global ./strings/substr_bench.nit -m ../lib/standard/ropes.nit --make-flags "CFLAGS=\"-g -O2 -DNOBOEHM\"" + + prepare_res substr_ropes.out substr_ropes ropes + if $verbose; then + echo "Ropes :" + fi + for i in `seq 1 "$1"`; do + if $verbose; then + echo "String length = $i, loops = $2, Loops = $3" + fi + bench_command $i ropes$i ./substr_bench -m flatstr --loops $2 --strlen $3 --ccts $i "NIT_GC_CHOOSER=large" + done + + ../bin/nitg --global ./strings/substr_bench.nit -m ../lib/standard/ropes.nit -m ../lib/buffered_ropes.nit --make-flags "CFLAGS=\"-g -O2 -DNOBOEHM\"" + + prepare_res substr_buf_ropes.out substr_buf_ropes buf_ropes + if $verbose; then + echo "Buffered Ropes :" + fi + for i in `seq 1 "$1"`; do + if $verbose; then + echo "String length = $i, loops = $2, Loops = $3" + fi + bench_command $i buf_ropes$i ./substr_bench -m flatstr --loops $2 --strlen $3 --ccts $i "NIT_GC_CHOOSER=large" + done plot substr.gnu } @@ -340,17 +443,6 @@ if test $# -ne 4; then exit fi -if $verbose; then - echo "Compiling" -fi - -../bin/nitg --global ./strings/chain_concat.nit --make-flags "CFLAGS=\"-g -O2 -DNOBOEHM\"" -../bin/nitg --global ./strings/utf_chain_concat.nit --make-flags "CFLAGS=\"-g -O2 -DNOBOEHM\"" -../bin/nitg --global ./strings/iteration_bench.nit --make-flags "CFLAGS=\"-g -O2 -DNOBOEHM\"" -../bin/nitg --global ./strings/utf_iteration_bench.nit --make-flags "CFLAGS=\"-g -O2 -DNOBOEHM\"" -../bin/nitg --global ./strings/substr_bench.nit --make-flags "CFLAGS=\"-g -O2 -DNOBOEHM\"" -../bin/nitg --global ./strings/utf_substr_bench.nit --make-flags "CFLAGS=\"-g -O2 -DNOBOEHM\"" - case "$1" in iter) shift; bench_iteration $@ ;; cct) shift; bench_concat $@ ;;