-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy paththroughput.nim
37 lines (32 loc) · 862 Bytes
/
throughput.nim
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
import nimuring
import std/[times]
const repeat = 1_000_000
type
Event = object
a: int
b: int
proc run(entries: int) =
var q = newQueue(entries, {})
var count = 0
# run 1 million nops to check queue throughput
var time = cpuTime()
var cqes = newSeq[Cqe](entries*2)
while count < repeat:
for i in 0..<entries:
var ev: ptr Event
when defined(userdata):
ev = create(Event)
else:
ev = cast[ptr Event](i)
q.nop(ev)
q.submit()
let cqesCount = q.copyCqes(cqes, entries.uint)
when defined(userdata):
for i in 0..<cqesCount:
dealloc(cast[ptr Event](cqes[i].userData))
count += cqesCount
time = cpuTime() - time
var rps = repeat / time
echo q.params.sqEntries, " ", rps
for entries in @[64, 128, 256, 512, 1024, 2048, 4096]:
run(entries)