Skip to content

Commit

Permalink
allow seconds to be a non-Float64
Browse files Browse the repository at this point in the history
  • Loading branch information
LilithHafner committed Feb 18, 2024
1 parent df2f93b commit cff553d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Chairmarks"
uuid = "0ca39b1e-fe0b-4e98-acfc-b1656634c4de"
authors = ["Lilith Orion Hafner <[email protected]> and contributors"]
version = "0.2.0"
version = "0.2.1"

[deps]
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Expand Down
2 changes: 1 addition & 1 deletion src/benchmarking.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ maybecall(::Nothing, x::Tuple{}) = x
maybecall(f, x::Tuple{Any}) = (f(only(x)),)
maybecall(f::Function, ::Tuple{}) = (f(),)
maybecall(x, ::Tuple{}) = (x,)
function benchmark(init, setup, f, teardown; evals::Union{Int, Nothing}=nothing, samples::Union{Int, Nothing}=nothing, seconds::Union{Float64, Nothing}=samples===nothing ? .1 : 1, map=default_map, reduction=default_reduction)
function benchmark(init, setup, f, teardown; evals::Union{Int, Nothing}=nothing, samples::Union{Int, Nothing}=nothing, seconds::Union{Real, Nothing}=samples===nothing ? .1 : 1, map=default_map, reduction=default_reduction)
@nospecialize
samples !== nothing && evals === nothing && throw(ArgumentError("Sorry, we don't support specifying samples but not evals"))
samples === seconds === nothing && throw(ArgumentError("Must specify either samples or seconds"))
Expand Down
5 changes: 5 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ using Statistics
@test Chairmarks.median([1, 2, 3]) === 2.0
@test Chairmarks.median((rand(1:3) for _ in 1:30 for _ in 1:30)) === 2.0
end

@testset "seconds kw" begin
@b 1+1 seconds=1
@b 1+1 seconds=.001
end
end

@testset "Precision" begin
Expand Down

2 comments on commit cff553d

@LilithHafner
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/101123

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.1 -m "<description of version>" cff553db1d0b7edeb8e190d0bf3aa8a7a1cee0b0
git push origin v0.2.1

Please sign in to comment.