Skip to content

Commit 3a9db26

Browse files
committed
Add tests that running under perf works
1 parent 8179bc5 commit 3a9db26

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

test/ExecutionTests.jl

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module ExecutionTests
33
using BenchmarkTools
44
using Profile
55
using Test
6+
using LinuxPerf
67

78
seteq(a, b) = length(a) == length(b) == length(intersect(a, b))
89

@@ -382,4 +383,34 @@ b = x = nothing
382383
GC.gc()
383384
@test x_finalized
384385

386+
##################################
387+
# Linux Perf Integration #
388+
##################################
389+
390+
b = @benchmarkable sin($(Ref(42.0))[])
391+
results = run(b; seconds=1, enable_linux_perf=false)
392+
@test results.linux_perf_stats === nothing
393+
394+
b = @benchmarkable sin($(Ref(42.0))[])
395+
results = run(b; seconds=1)
396+
@test results.linux_perf_stats === nothing
397+
398+
b = @benchmarkable sin($(Ref(42.0))[])
399+
results = run(b; seconds=1, enable_linux_perf=true, evals=10^3)
400+
@test results.linux_perf_stats !== nothing
401+
@test any(results.linux_perf_stats.threads) do thread
402+
instructions = LinuxPerf.scaledcount(thread["instructions"])
403+
!isnan(instructions) && instructions > 10^4
404+
end
405+
406+
tune!(groups)
407+
results = run(groups; enable_linux_perf=true)
408+
for (name, group_results) in BenchmarkTools.leaves(results)
409+
@test group_results.linux_perf_stats !== nothing
410+
@test any(group_results.linux_perf_stats.threads) do thread
411+
instructions = LinuxPerf.scaledcount(thread["instructions"])
412+
!isnan(instructions) && instructions > 10^3
413+
end
414+
end
415+
385416
end # module

0 commit comments

Comments
 (0)