From 753402041d95f4fe50705e284c5a7efed882a68e Mon Sep 17 00:00:00 2001 From: Alexius Wadell Date: Tue, 16 Jul 2024 13:23:30 -0400 Subject: [PATCH] feat: define the public interface --- Project.toml | 4 +++- docs/src/ci.md | 1 - src/PkgJogger.jl | 18 ++---------------- src/ci.jl | 2 +- src/jogger.jl | 14 ++++++++++---- 5 files changed, 16 insertions(+), 23 deletions(-) diff --git a/Project.toml b/Project.toml index fd2a84a..d1ce54c 100644 --- a/Project.toml +++ b/Project.toml @@ -7,6 +7,7 @@ version = "0.6.0" BSON = "fbb218c0-5317-5bc6-957e-2ee96dd4b1f0" BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" CodecZlib = "944b1d66-785c-5afd-91f1-9de20f533193" +Compat = "34da2185-b29b-5c13-b0c7-acf172513d20" Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" LibGit2 = "76f85450-5226-5b5a-8eaa-529ad045b433" @@ -28,13 +29,14 @@ BSON = "0.3" BenchmarkTools = "1.5" CUDA = "5" CodecZlib = "0.7" +Compat = "4.11, 4.15" Dates = "1.9" JSON = "0.21" LibGit2 = "1.9" -Revise = "3" NVTX = "0.3" Pkg = "1.9" Profile = "1.9" +Revise = "3" Statistics = "1.9" Test = "1.9" UUIDs = "1.9" diff --git a/docs/src/ci.md b/docs/src/ci.md index c08edc7..84684cb 100644 --- a/docs/src/ci.md +++ b/docs/src/ci.md @@ -70,5 +70,4 @@ PkgJogger.@test_benchmarks ```@docs PkgJogger.ci -PkgJogger.JOGGER_PKGS ``` diff --git a/src/PkgJogger.jl b/src/PkgJogger.jl index 132fe6c..e0c774e 100644 --- a/src/PkgJogger.jl +++ b/src/PkgJogger.jl @@ -11,24 +11,10 @@ using LibGit2 using Statistics using Test using Profile +using Compat export @jog, @test_benchmarks - -import Base: PkgId -""" -Packages that are required by modules created with [`@jog`](@ref) - -Generated modules will access these via `Base.loaded_modules` -""" -const JOGGER_PKGS = [ - Base.identify_package(@__MODULE__, string(@__MODULE__)), - PkgId(UUID("6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"), "BenchmarkTools"), - PkgId(UUID("cf7118a7-6976-5b1a-9a39-7adc72f591a4"), "UUIDs"), -] - -const PKG_JOGGER_VER = VersionNumber( - Base.parsed_toml(joinpath(@__DIR__, "..", "Project.toml"))["version"] -) +@compat public judge, ci, load_benchmarks, save_benchmarks, locate_benchmarks, tune!, getsuite include("utils.jl") include("profile.jl") diff --git a/src/ci.jl b/src/ci.jl index 43ce966..ac8ae71 100644 --- a/src/ci.jl +++ b/src/ci.jl @@ -118,7 +118,7 @@ function save_benchmarks(filename, results::BenchmarkTools.BenchmarkGroup) "datetime" => Dates.now(), "benchmarks" => results, "git" => git_info(filename), - "pkgjogger" => PkgJogger.PKG_JOGGER_VER, + "pkgjogger" => pkgversion(@__MODULE__), ) # Write benchmark to disk diff --git a/src/jogger.jl b/src/jogger.jl index dd658b4..4b9009e 100644 --- a/src/jogger.jl +++ b/src/jogger.jl @@ -74,7 +74,13 @@ macro jog(pkg) quote @eval module $modname using $pkg - $(using_statements...) + using Compat: @public + using UUIDs: uuid4 + using PkgJogger: PkgJogger + using BenchmarkTools: BenchmarkTools + + # The public interface of a Jogger + @public suite, benchmark, run, profile, save_benchmarks, load_benchmarks, judge, BENCHMARK_DIR # Set Revise Mode and put submodules here __revise_mode__ = :eval @@ -195,7 +201,7 @@ macro jog(pkg) """ function save_benchmarks(results) - filename = joinpath(BENCHMARK_DIR, "trial", "$(UUIDs.uuid4()).bson.gz") + filename = joinpath(BENCHMARK_DIR, "trial", "$(uuid4()).bson.gz") PkgJogger.save_benchmarks(filename, results) filename end @@ -240,13 +246,13 @@ macro jog(pkg) ```julia # Judge results by UUID - $($mod_str).judge("$(UUIDs.uuid4())", "$(UUIDs.uuid4())") + $($mod_str).judge("$(uuid4())", "$(uuid4())") [...] ``` ```julia # Judge using the minimum, instead of the median, time - $($mod_str).judge("path/to/results.bson.gz", "$(UUIDs.uuid4())"; metric=minimum) + $($mod_str).judge("path/to/results.bson.gz", "$(uuid4())"; metric=minimum) [...] ``` """