-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Use more Tuples * Performance tests
- Loading branch information
Showing
4 changed files
with
46 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
BenchmarkTools |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# compare performance with plain assertion | ||
using BenchmarkTools | ||
using ArgCheck | ||
|
||
truthy(x) = true | ||
|
||
function fallback_argcheck(x) | ||
@argcheck x | ||
end | ||
function comparison_argcheck(x) | ||
@argcheck x == 42 | ||
end | ||
function call_argcheck(x) | ||
@argcheck truthy(x) | ||
end | ||
function fallback_assert(x) | ||
@assert x | ||
end | ||
function comparison_assert(x) | ||
@assert x == 42 | ||
end | ||
function call_assert(x) | ||
@assert truthy(x) | ||
end | ||
|
||
benchmarks =[ | ||
(fallback_assert, fallback_argcheck, true), | ||
(call_assert, call_argcheck, 42), | ||
(comparison_assert, comparison_argcheck, 42), | ||
] | ||
|
||
for (f_argcheck, f_assert, arg) in benchmarks | ||
println(f_argcheck) | ||
@btime ($f_argcheck)($arg) | ||
println(f_assert) | ||
@btime ($f_assert)($arg) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ else | |
end | ||
|
||
include("checks.jl") | ||
include("perf.jl") |