|
| 1 | +module LinuxPerfIntegrationTests |
| 2 | + |
| 3 | +using BenchmarkTools |
| 4 | +using Test |
| 5 | +using LinuxPerf |
| 6 | + |
| 7 | +### Serialization Test ### |
| 8 | +b = @benchmarkable sin(1) enable_linux_perf = true |
| 9 | +tune!(b) |
| 10 | +bb = run(b) |
| 11 | + |
| 12 | +withtempdir() do |
| 13 | + tmp = joinpath(pwd(), "tmp.json") |
| 14 | + |
| 15 | + BenchmarkTools.save(tmp, b.params, bb) |
| 16 | + @test isfile(tmp) |
| 17 | + |
| 18 | + results = BenchmarkTools.load(tmp) |
| 19 | + @test results isa Vector{Any} |
| 20 | + @test length(results) == 2 |
| 21 | + @test eq(results[1], b.params) |
| 22 | + @test eq(results[2], bb) |
| 23 | +end |
| 24 | + |
| 25 | +################################## |
| 26 | +# Linux Perf Integration # |
| 27 | +################################## |
| 28 | + |
| 29 | +b = @benchmarkable sin($(Ref(42.0))[]) |
| 30 | +results = run(b; seconds=1, enable_linux_perf=false) |
| 31 | +@test results.linux_perf_stats === nothing |
| 32 | + |
| 33 | +b = @benchmarkable sin($(Ref(42.0))[]) |
| 34 | +results = run(b; seconds=1) |
| 35 | +@test results.linux_perf_stats === nothing |
| 36 | + |
| 37 | +b = @benchmarkable sin($(Ref(42.0))[]) |
| 38 | +results = run(b; seconds=1, enable_linux_perf=true, evals=10^3) |
| 39 | +@test results.linux_perf_stats !== nothing |
| 40 | +@test any(results.linux_perf_stats.threads) do thread |
| 41 | + instructions = LinuxPerf.scaledcount(thread["instructions"]) |
| 42 | + !isnan(instructions) && instructions > 10^4 |
| 43 | +end |
| 44 | + |
| 45 | +tune!(groups) |
| 46 | +results = run(groups; enable_linux_perf=true) |
| 47 | +for (name, group_results) in BenchmarkTools.leaves(results) |
| 48 | + @test group_results.linux_perf_stats !== nothing |
| 49 | + @test any(group_results.linux_perf_stats.threads) do thread |
| 50 | + instructions = LinuxPerf.scaledcount(thread["instructions"]) |
| 51 | + !isnan(instructions) && instructions > 10^3 |
| 52 | + end |
| 53 | +end |
| 54 | + |
| 55 | +end |
0 commit comments