Skip to content

Commit 7b1da5d

Browse files
committed
Determine if perf is available more accurately
1 parent 6f27943 commit 7b1da5d

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/parameters.jl

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,24 @@ mutable struct Parameters
1919
linux_perf_options::@NamedTuple{events::Expr, spaces::Expr, threads::Bool}
2020
end
2121

22-
# TODO: determine whether perf is available
22+
function perf_available()
23+
if !Sys.islinux()
24+
return false
25+
end
26+
27+
try
28+
opts = LinuxPerf.parse_pstats_options([])
29+
groups = BenchmarkTools.LinuxPerf.set_default_spaces(
30+
opts.events,
31+
opts.spaces,
32+
)
33+
bench = make_bench_threaded(groups, threads = opts.threads)
34+
return true
35+
catch
36+
return false
37+
end
38+
end
39+
2340
const DEFAULT_PARAMETERS = Parameters(
2441
5.0,
2542
10000,
@@ -30,7 +47,7 @@ const DEFAULT_PARAMETERS = Parameters(
3047
false,
3148
0.05,
3249
0.01,
33-
Sys.islinux(),
50+
perf_available(),
3451
LinuxPerf.parse_pstats_options([]),
3552
)
3653

0 commit comments

Comments
 (0)