From e79fef77ab391d7324000fe4996ff23c4e0bbe09 Mon Sep 17 00:00:00 2001 From: Jeff Fessler Date: Tue, 1 Feb 2022 18:12:30 -0500 Subject: [PATCH 1/4] btime options --- Project.toml | 2 +- src/timer.jl | 8 +++++--- test/timer.jl | 8 ++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Project.toml b/Project.toml index 727ca5d..5ef26cf 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "LazyGrids" uuid = "7031d0ef-c40d-4431-b2f8-61a8d2f650db" authors = ["Sheehan Olver ", "Jeff Fessler "] -version = "0.2.0" +version = "0.2.1" [deps] Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" diff --git a/src/timer.jl b/src/timer.jl index 3ed76dc..378d082 100644 --- a/src/timer.jl +++ b/src/timer.jl @@ -38,12 +38,14 @@ end """ - btime() + btime(t ; scale, digits) Pretty-print the @benchmark output for non-interactive use with Literate. Returns a string so that Literate will capture the output. +* `scale` is `10^6` by default, for reporting in ms. Use `10^3` for μs. +* `digits` is 1 by default. """ -btime(t) = string( - "time=", round(median(t.times)/10^6, digits=1), # median time in ms +btime(t; scale::Real=10^6, digits::Int=1) = string( + "time=", round(median(t.times)/scale; digits), # median time in ms "ms mem=", t.memory, " alloc=", t.allocs, ) diff --git a/test/timer.jl b/test/timer.jl index a3818d1..6922f76 100644 --- a/test/timer.jl +++ b/test/timer.jl @@ -5,9 +5,9 @@ using BenchmarkTools: @benchmark using Test: @test, @testset, @test_throws, @inferred @testset "timer" begin - t = @benchmark sum(1:7) - @inferred btime(t) - @test btime(t) isa String + t = @benchmark sum(1:7) + @inferred btime(t) + @test btime(t) isa String - @test (@timeo sum(1:7)) isa String + @test (@timeo sum(1:7)) isa String end From 3814fa98dae700e995f8788863bf36517def86b9 Mon Sep 17 00:00:00 2001 From: Jeff Fessler Date: Tue, 1 Feb 2022 18:14:18 -0500 Subject: [PATCH 2/4] test 1.6 --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 49126b6..6fa03d2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,9 @@ jobs: fail-fast: false matrix: version: + - '1.6' - '1' + - 'nightly' os: - ubuntu-latest - macOS-latest From ab7f76a6349ef160b4ec68dfd2bbfd54e0f289b5 Mon Sep 17 00:00:00 2001 From: Jeff Fessler Date: Tue, 1 Feb 2022 19:00:36 -0500 Subject: [PATCH 3/4] units --- src/timer.jl | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/timer.jl b/src/timer.jl index 378d082..9207f4e 100644 --- a/src/timer.jl +++ b/src/timer.jl @@ -38,14 +38,14 @@ end """ - btime(t ; scale, digits) + btime(t ; unit::Symbol, digits::Int) Pretty-print the @benchmark output for non-interactive use with Literate. Returns a string so that Literate will capture the output. -* `scale` is `10^6` by default, for reporting in ms. Use `10^3` for μs. +* `unit` is `:ms` by default, for reporting in ms. Or use `μs`. * `digits` is 1 by default. """ -btime(t; scale::Real=10^6, digits::Int=1) = string( - "time=", round(median(t.times)/scale; digits), # median time in ms - "ms mem=", t.memory, - " alloc=", t.allocs, -) +function btime(t ; unit::Symbol = :ms, digits::Int = 1) + scale = unit == :ms ? 10^6 : unit == :μs ? 10^3 : throw("unit $unit") + time = round(median(t.times)/scale; digits) # median time in units + string("time=", time, unit, " mem=", t.memory, " alloc=", t.allocs) +end From a0bab2efa43e3d40f6932da245d597c4137d9f4e Mon Sep 17 00:00:00 2001 From: Jeff Fessler Date: Tue, 1 Feb 2022 19:08:34 -0500 Subject: [PATCH 4/4] CI for PR only --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6fa03d2..20c340c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,8 @@ name: CI on: push: + branches: + - main paths-ignore: - '*/*.md' - 'docs/**'