1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # This file is free software, which comes along with NIT. This software is
4 # distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
5 # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
6 # PARTICULAR PURPOSE. You can modify it is you want, provided this header
7 # is kept unaltered, and a notification of the changes is added.
8 # You are allowed to redistribute it and sell it, alone or is a part of
11 # Benches measuring the performance of several concatenations on Text variants
12 module utf_chain_concat
15 import string_experimentations
::utf8_noindex
17 fun bench_flatstr
(str_size
: Int, nb_ccts
: Int, loops
: Int)
19 var lft
= "a" * str_size
21 for i
in [0..loops
] do
23 for j
in [0..nb_ccts
] do
29 var opts
= new OptionContext
30 var nb_ccts
= new OptionInt("Number of concatenations per loop", -1, "--ccts")
31 var loops
= new OptionInt("Number of loops to be done", -1, "--loops")
32 var strlen
= new OptionInt("Length of the base string", -1, "--strlen")
33 opts
.add_option
(nb_ccts
, loops
, strlen
)
37 if nb_ccts
.value
== -1 or loops
.value
== -1 or strlen
.value
== -1 then
42 bench_flatstr
(strlen
.value
, nb_ccts
.value
, loops
.value
)