nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
nitunit manual: document NIT_TESTING, SRAND and NIT_TESTING_ID
[nit.git]
/
tests
/
bench_string_append.nit
diff --git
a/tests/bench_string_append.nit
b/tests/bench_string_append.nit
index
1856a7a
..
b7df069
100644
(file)
--- a/
tests/bench_string_append.nit
+++ b/
tests/bench_string_append.nit
@@
-14,7
+14,10
@@
# See the License for the specific language governing permissions and
# limitations under the License.
# See the License for the specific language governing permissions and
# limitations under the License.
-var n = 7
+#alt1 import core
+#alt1 import core::text::ropes
+
+var n = 4
if not args.is_empty then
n = args.first.to_i
end
if not args.is_empty then
n = args.first.to_i
end
@@
-22,7
+25,8
@@
end
var s = "*"
var i = 0
while i < n do
var s = "*"
var i = 0
while i < n do
- var s2 = "Je dis «"
+ var s2: Buffer = new FlatBuffer.from("Je dis «")
+ #alt1 s2 = new RopeBuffer.from("Je dis «")
s2.append(s)
s2.append("» et redis «")
s2.append(s)
s2.append(s)
s2.append("» et redis «")
s2.append(s)
@@
-30,25
+34,24
@@
while i < n do
s2.append(s)
s2.append(s)
s2.append("».\n")
s2.append(s)
s2.append(s)
s2.append("».\n")
- s = s2
+ s = s2.to_s
i = i + 1
end
i = i + 1
end
-print("Je dis «Je dis".search_all_in(s).length)
+print(s.search_all("Je dis «Je dis").length)
i = 0
var j = 0
while j >= 0 do
i = 0
var j = 0
while j >= 0 do
- j = "Je dis «Je dis".search_index_in(s, j)
- if j >= 0 then
- i = i + 1
- j = j + 1
- end
+ var r = s.search_from("Je dis «Je dis", j)
+ if r == null then break
+ i = i + 1
+ j = r.from + 1
end
print(i)
i = 0
for k in [0..s.length[ do
end
print(i)
i = 0
for k in [0..s.length[ do
- var c = s[k]
+ var c = s.chars[k]
if c >= 'a' and c <= 'z' then
i = i + 1
end
if c >= 'a' and c <= 'z' then
i = i + 1
end