-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add BenchmarkTools integration #1
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
name = "ValgrindBenchmarkTools" | ||
uuid = "cddf0403-163e-426d-bfc7-5afd20e79fa3" | ||
authors = ["Valentin Churavy <[email protected]>"] | ||
version = "0.1.0" | ||
|
||
[deps] | ||
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" | ||
Reexport = "189a3867-3050-52da-a836-e630ba90ab69" | ||
Valgrind = "a52a33a2-b08a-4c46-b084-8041b090a67d" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using BenchmarkTools | ||
using ValgrindBenchmarkTools | ||
|
||
@noinline function g(a) | ||
c = 0 | ||
for x in a | ||
if x > 0 | ||
c += 1 | ||
end | ||
end | ||
c | ||
end | ||
const data = zeros(10000) | ||
|
||
@show @benchmark g($data) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
module ValgrindBenchmarkTools | ||
|
||
using Valgrind, Reexport | ||
@reexport using BenchmarkTools | ||
|
||
@inline function prehook() | ||
Valgrind.Callgrind.zero_stats() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could move |
||
Valgrind.Callgrind.start_instrumentation() | ||
end | ||
|
||
@inline function posthook(id) | ||
Valgrind.Callgrind.stop_instrumentation() | ||
Valgrind.Callgrind.dump_stats_at(id) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm guessing you want |
||
end | ||
|
||
function __init__() | ||
BenchmarkTools.DEFAULT_PARAMETERS = BenchmarkTools.Parameters(; | ||
prehook = prehook, | ||
posthook = posthook, | ||
enable_customizable_func = :ALL, | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you don't want to run the normal benchmarking BenchmarkTools does you can set |
||
|
||
# Serialization | ||
BenchmarkTools.VERSIONS["Valgrind"] = pkgversion(Valgrind) | ||
BenchmarkTools.VERSIONS["ValgrindBenchmarkTools.jl"] = | ||
pkgversion(ValgrindBenchmarkTools) | ||
end | ||
|
||
|
||
end # module ValgrindBenchmarkTools |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Been a while since I touched this code, but don't think you need this.