bench_command $i flatbuffer$i ./chain_concat -m flatbuf --loops $2 --strlen $3 --ccts $i "NIT_GC_CHOOSER=large"
done
+ prepare_res concat_flatstr_utf8_noindex.out concat_flatstr_utf8_noindex flatstring_utf8_noindex
+ if $verbose; then
+ echo "FlatString UTF-8 (without index) :"
+ fi
+ for i in `seq 1 "$1"`; do
+ if $verbose; then
+ echo "String length = $i, Concats/loop = $2, Loops = $3"
+ fi
+ 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
}
bench_command $i flatbuf_index$i ./iteration_bench -m flatbuf --iter-mode index --loops $2 --strlen $3 --ccts $i "NIT_GC_CHOOSER=large"
done
+ prepare_res iter_flat_utf8_noindex_iter.out iter_flat_iter_utf8_noindex flatstring_utf8_noindex_iter
+ if $verbose; then
+ echo "FlatStrings by iterator :"
+ fi
+ for i in `seq 1 "$1"`; do
+ if $verbose; then
+ echo "String base length = $1, Concats = $i, Loops = $3"
+ fi
+ bench_command $i flatstr_iter_utf8_noindex$i ./utf_iteration_bench -m flatstr_utf8_noindex --iter-mode iterator --loops $2 --strlen $3 --ccts $i "NIT_GC_CHOOSER=large"
+ done
+
+ prepare_res iter_flat_utf8_noindex_index.out iter_flat_index_utf8_noindex flatstring_utf8_noindex_index
+ if $verbose; then
+ echo "FlatStrings by index :"
+ fi
+ for i in `seq 1 "$1"`; do
+ if $verbose; then
+ echo "String base length = $1, Concats = $i, Loops = $3"
+ fi
+ 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
}
bench_command $i flatbuffer$i ./substr_bench -m flatbuf --loops $2 --strlen $3 --ccts $i "NIT_GC_CHOOSER=large"
done
+ prepare_res substr_flat_utf8_noindex.out substr_flat_utf8_noindex flatstring_utf8_noindex
+ if $verbose; then
+ echo "FlatStrings UTF-8 (without index) :"
+ fi
+ for i in `seq 1 "$1"`; do
+ if $verbose; then
+ echo "String length = $i, loops = $2, Loops = $3"
+ fi
+ 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
+
plot substr.gnu
}
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 $@ ;;
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# This file is free software, which comes along with NIT. This software is
+# distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. You can modify it is you want, provided this header
+# is kept unaltered, and a notification of the changes is added.
+# You are allowed to redistribute it and sell it, alone or is a part of
+# another product.
+
+# Benches measuring the performance of several concatenations on Text variants
+module utf_chain_concat
+
+import opts
+import string_experimentations::utf8_noindex
+
+fun bench_flatstr(str_size: Int, nb_ccts: Int, loops: Int)
+do
+ var lft = "a" * str_size
+
+ for i in [0..loops] do
+ var str: String = lft
+ for j in [0..nb_ccts] do
+ str += lft
+ end
+ end
+end
+
+var opts = new OptionContext
+var nb_ccts = new OptionInt("Number of concatenations per loop", -1, "--ccts")
+var loops = new OptionInt("Number of loops to be done", -1, "--loops")
+var strlen = new OptionInt("Length of the base string", -1, "--strlen")
+opts.add_option(nb_ccts, loops, strlen)
+
+opts.parse(args)
+
+if nb_ccts.value == -1 or loops.value == -1 or strlen.value == -1 then
+ opts.usage
+ exit -1
+end
+
+bench_flatstr(strlen.value, nb_ccts.value, loops.value)
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# This file is free software, which comes along with NIT. This software is
+# distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. You can modify it is you want, provided this header
+# is kept unaltered, and a notification of the changes is added.
+# You are allowed to redistribute it and sell it, alone or is a part of
+# another product.
+
+# Benches for iteration on variants of Text
+module utf_iteration_bench
+
+import opts
+import string_experimentations::utf8_noindex
+
+fun bench_flatstr_iter(nb_cct: Int, loops: Int, strlen: Int)
+do
+ var a = "a" * strlen
+ var x = a.as(FlatString)
+ for i in [0 .. nb_cct] do x = (x + a).as(FlatString)
+ var cnt = 0
+ var c: UnicodeChar
+ while cnt != loops do
+ var it = new FlatStringIter(x)
+ for i in it do
+ c = i
+ end
+ cnt += 1
+ end
+end
+
+fun bench_flatstr_index(nb_cct: Int, loops: Int, strlen: Int)
+do
+ var a = "a" * strlen
+ var x = a.as(FlatString)
+ for i in [0 .. nb_cct] do x = (x + a).as(FlatString)
+ var cnt = 0
+ var c: UnicodeChar
+ var pos = 0
+ while cnt != loops do
+ pos = 0
+ while pos < x.length do
+ c = x.char_at(pos)
+ pos += 1
+ end
+ cnt += 1
+ end
+end
+
+var opts = new OptionContext
+var access_mode = new OptionEnum(["iterator", "index"], "Iteration mode", -1, "--iter-mode")
+var nb_ccts = new OptionInt("Number of concatenations done to the string (in the case of the rope, this will increase its depth)", -1, "--ccts")
+var loops = new OptionInt("Number of loops to be done", -1, "--loops")
+var strlen = new OptionInt("Length of the base string", -1, "--strlen")
+opts.add_option(nb_ccts, loops, strlen, access_mode)
+
+opts.parse(args)
+
+if nb_ccts.value == -1 or loops.value == -1 or strlen.value == -1 then
+ opts.usage
+ exit(-1)
+end
+
+var iterval = access_mode.value
+
+if iterval == 0 then
+ bench_flatstr_iter(nb_ccts.value, loops.value, strlen.value)
+else if iterval == 1 then
+ bench_flatstr_index(nb_ccts.value, loops.value, strlen.value)
+else
+ opts.usage
+ exit(-1)
+end
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# This file is free software, which comes along with NIT. This software is
+# distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. You can modify it is you want, provided this header
+# is kept unaltered, and a notification of the changes is added.
+# You are allowed to redistribute it and sell it, alone or is a part of
+# another product.
+
+# Benches on the substring operation on variants of Text
+module utf_substr_bench
+
+import opts
+import string_experimentations::utf8_noindex
+
+fun bench_flatstr(nb_cct: Int, loops: Int, strlen: Int)
+do
+ var a = "a" * strlen
+ var x = a
+ for i in [0 .. nb_cct] do x += a
+ var cnt = 0
+ while cnt != loops do
+ x.substring(0,5)
+ cnt += 1
+ end
+end
+
+var opts = new OptionContext
+var nb_ccts = new OptionInt("Number of concatenations done to the string (in the case of the rope, this will increase its depth)", -1, "--ccts")
+var loops = new OptionInt("Number of loops to be done", -1, "--loops")
+var strlen = new OptionInt("Length of the base string", -1, "--strlen")
+opts.add_option(nb_ccts, loops, strlen)
+
+opts.parse(args)
+
+if nb_ccts.value == -1 or loops.value == -1 or strlen.value == -1 then
+ opts.usage
+ exit(-1)
+end
+
+bench_flatstr(nb_ccts.value, loops.value, strlen.value)