forked from IoLanguage/io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
perf.io
54 lines (39 loc) · 1.12 KB
/
perf.io
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
max := 10000
db := TokyoCabinet clone
File with("test.db") remove
db open("test.db")
s1 := Date secondsToRun(
db begin
for(i, 1, max, db atPut("001/" .. i, "v"))
db commit
)
writeln((max/s1) asString(0, 0), " group writes per second")
s1 := Date secondsToRun(
for(i, 1, max, db at("001/" .. i))
)
writeln((max/s1) asString(0, 0), " reads per second")
s1 := Date secondsToRun(
c := db cursor
i := 1
c first
while(c next, c key; i = i + 1)
if(i != max, Exception raise("cursor read " .. i .. " entries instead of " .. max))
c close
)
writeln((max/s1) asString(0, 0), " cursor reads per second")
s1 := Date secondsToRun(
db begin
for(i, 1, max, db removeAt("001/" .. i))
db commit
)
writeln((max/s1) asString(0, 0), " group removes per second\n")
s1 := Date secondsToRun(
for(i, 1, max, db transactionalAtPut("001/" .. i, "v"))
)
writeln((max/s1) asString(0, 0), " individual writes per second")
s1 := Date secondsToRun(
for(i, 1, max, db transactionalRemoveAt("001/" .. i))
)
writeln((max/s1) asString(0, 0), " individual removes per second")
// -----------------------------------------------
db close