Skip to content

Commit

Permalink
Functional Chainmarks extension
Browse files Browse the repository at this point in the history
  • Loading branch information
VarLad committed Apr 29, 2024
1 parent da8b5af commit 386427b
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 28 deletions.
3 changes: 3 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@ TypedTables = "9d95f2ec-7b3d-5a63-8d20-e2491e220bb9"

[weakdeps]
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
Chairmarks = "0ca39b1e-fe0b-4e98-acfc-b1656634c4de"

[extensions]
BenchmarkToolsExt = "BenchmarkTools"
ChairmarksExt = "Chairmarks"

[compat]
BenchmarkTools = "1.5.0"
Chairmarks = "1.2"
CoverageTools = "1"
CpuId = "0.3.1"
TypedTables = "1"
Expand Down
25 changes: 0 additions & 25 deletions ext/ChainmarksExt/b.jl

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module ChainmarksExt
module ChairmarksExt

using Chainmarks
using PerfChecker
import TypedTables: Table

include("b.jl")
include("be.jl")
include("chairmark.jl")
#include("be.jl")
#include("chairmark.jl")
end

36 changes: 36 additions & 0 deletions ext/ChairmarksExt/b.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
function PerfChecker.default_options(::Val{:chairmark})
return Dict(
:threads => 1,
:track => "none",
:init => nothing,
:setup => nothing,
:f => nothing,
:teardown => nothing,
:kwargs => ()
)
end

function PerfChecker.check(d::Dict, block::Expr, ::Val{:chairmark})
if d[:f] == nothing
d[:f] = @eval () -> $block
end
quote
d = $d
using Chairmarks
return Chairmarks.benchmark(d[:init], d[:setup], d[:f], d[:teardown]; d[:kwargs]...)
end
end

PerfChecker.prep(::Dict, block::Expr, ::Val{:chairmark}) = quote
$block
nothing
end

PerfChecker.post(d::Dict, ::Val{:chairmark}) = d[:check_result]
#=
function PerfChecker.to_table(bench::BenchmarkTools.Trial)
ti = bench.times
l = length(ti)
return Table(times=ti, gctimes=bench.gctimes, memory=fill(bench.memory, l), allocs=fill(bench.allocs, l))
end
=#
2 changes: 2 additions & 0 deletions src/PerfChecker.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ struct HwInfo
corecount::Tuple{Int, Int, Int}
end

println("Hell")

struct CheckerResult
tables::Vector{Table}
hwinfo::Union{HwInfo,Nothing}
Expand Down

0 comments on commit 386427b

Please sign in to comment.