Skip to content

Commit 28042db

Browse files
committed
Add field to store perf results
1 parent 8ef06d7 commit 28042db

File tree

1 file changed

+30
-5
lines changed

1 file changed

+30
-5
lines changed

src/trials.jl

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ mutable struct Trial
88
gctimes::Vector{Float64}
99
memory::Int
1010
allocs::Int
11+
linux_perf_stats::Union{LinuxPerf.Stats,Nothing}
12+
13+
function Trial(params, times, gctimes, memory, allocs, linux_perf_stats=nothing)
14+
return new(params, times, gctimes, memory, allocs, linux_perf_stats)
15+
end
1116
end
1217

1318
Trial(params::Parameters) = Trial(params, Float64[], Float64[], typemax(Int), typemax(Int))
@@ -21,7 +26,14 @@ function Base.:(==)(a::Trial, b::Trial)
2126
end
2227

2328
function Base.copy(t::Trial)
24-
return Trial(copy(t.params), copy(t.times), copy(t.gctimes), t.memory, t.allocs)
29+
return Trial(
30+
copy(t.params),
31+
copy(t.times),
32+
copy(t.gctimes),
33+
t.memory,
34+
t.allocs,
35+
t.linux_perf_stats,
36+
)
2537
end
2638

2739
function Base.push!(t::Trial, time, gctime, memory, allocs)
@@ -40,9 +52,13 @@ end
4052

4153
Base.length(t::Trial) = length(t.times)
4254
function Base.getindex(t::Trial, i::Number)
43-
return push!(Trial(t.params), t.times[i], t.gctimes[i], t.memory, t.allocs)
55+
return Trial(
56+
t.params, [t.times[i]], [t.gctimes[i]], t.memory, t.allocs, t.linux_perf_stats
57+
)
58+
end
59+
function Base.getindex(t::Trial, i)
60+
return Trial(t.params, t.times[i], t.gctimes[i], t.memory, t.allocs, t.linux_perf_stats)
4461
end
45-
Base.getindex(t::Trial, i) = Trial(t.params, t.times[i], t.gctimes[i], t.memory, t.allocs)
4662
Base.lastindex(t::Trial) = length(t)
4763

4864
function Base.sort!(t::Trial)
@@ -98,10 +114,17 @@ mutable struct TrialEstimate
98114
gctime::Float64
99115
memory::Int
100116
allocs::Int
117+
linux_perf_stats::Union{LinuxPerf.Stats,Nothing}
118+
119+
function TrialEstimate(params, times, gctime, memory, allocs, linux_perf_stats=nothing)
120+
return new(params, times, gctime, memory, allocs, linux_perf_stats)
121+
end
101122
end
102123

103124
function TrialEstimate(trial::Trial, t, gct)
104-
return TrialEstimate(params(trial), t, gct, memory(trial), allocs(trial))
125+
return TrialEstimate(
126+
params(trial), t, gct, memory(trial), allocs(trial), trial.linux_perf_stats
127+
)
105128
end
106129

107130
function Base.:(==)(a::TrialEstimate, b::TrialEstimate)
@@ -113,7 +136,9 @@ function Base.:(==)(a::TrialEstimate, b::TrialEstimate)
113136
end
114137

115138
function Base.copy(t::TrialEstimate)
116-
return TrialEstimate(copy(t.params), t.time, t.gctime, t.memory, t.allocs)
139+
return TrialEstimate(
140+
copy(t.params), t.time, t.gctime, t.memory, t.allocs, t.linux_perf_stats
141+
)
117142
end
118143

119144
function Base.minimum(trial::Trial)

0 commit comments

Comments
 (0)