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 on the substring operation on variants of Text
16 fun bench_flatstr
(nb_cct
: Int, loops
: Int, strlen
: Int)
20 for i
in [0 .. nb_cct
] do x
+= a
28 fun bench_flatbuf
(nb_cct
: Int, loops
: Int, strlen
: Int)
31 var x
= new FlatBuffer.from
(a
)
32 for i
in [0 .. nb_cct
] do x
.append a
40 var opts
= new OptionContext
41 var mode
= new OptionEnum(["flatstr", "flatbuf"], "Mode", -1, "-m")
42 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")
43 var loops
= new OptionInt("Number of loops to be done", -1, "--loops")
44 var strlen
= new OptionInt("Length of the base string", -1, "--strlen")
45 opts
.add_option
(mode
, nb_ccts
, loops
, strlen
)
49 if nb_ccts
.value
== -1 or loops
.value
== -1 or strlen
.value
== -1 then
54 var modval
= mode
.value
57 bench_flatstr
(nb_ccts
.value
, loops
.value
, strlen
.value
)
58 else if modval
== 1 then
59 bench_flatbuf
(nb_ccts
.value
, loops
.value
, strlen
.value
)