-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathbenchmarks.jl
57 lines (47 loc) · 1.36 KB
/
benchmarks.jl
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
54
55
56
57
using BenchmarkTools
using PythonCall
using PythonCall: pydel!, pyimport, pydict, pystr, pyrange
const SUITE = BenchmarkGroup()
function test_pydict_init()
random = pyimport("random").random
x = pydict()
for i in pyrange(1000)
x[pystr(i)] = i + random()
end
return x
end
SUITE["basic"]["julia"]["pydict"]["init"] = @benchmarkable test_pydict_init()
function test_pydict_pydel()
random = pyimport("random").random
x = pydict()
for i in pyrange(1000)
k = pystr(i)
r = random()
v = i + r
x[k] = v
pydel!(k)
pydel!(r)
pydel!(v)
pydel!(i)
end
return x
end
SUITE["basic"]["julia"]["pydict"]["pydel"] = @benchmarkable test_pydict_pydel()
@generated function test_atpy(::Val{use_pydel}) where {use_pydel}
quote
@py begin
import random: random
x = {}
for i in range(1000)
x[str(i)] = i + random()
$(use_pydel ? :(@jl PythonCall.pydel!(i)) : :(nothing))
end
x
end
end
end
SUITE["basic"]["@py"]["pydict"]["init"] = @benchmarkable test_atpy(Val(false))
SUITE["basic"]["@py"]["pydict"]["pydel"] = @benchmarkable test_atpy(Val(true))
include("gcbench.jl")
using .GCBench: append_lots
SUITE["gc"]["append_and_full_gc"] = @benchmarkable GC.gc(true) setup=(append_lots())