|
2 | 2 | # Trial # |
3 | 3 | ######### |
4 | 4 |
|
| 5 | +# Move into LinuxPerf.jl |
| 6 | +Base.copy(stats::LinuxPerf.Stats) = LinuxPerf.Stats(copy(stats.threads)) |
| 7 | +function Base.copy(thread_stats::LinuxPerf.ThreadStats) |
| 8 | + return LinuxPerf.ThreadStats(thread_stats.pid, copy(thread_stats.groups)) |
| 9 | +end |
| 10 | +function Base.copy(counter::LinuxPerf.Counter) |
| 11 | + return LinuxPerf.Counter( |
| 12 | + copy(counter.event), counter.value, counter.enabled, counter.running |
| 13 | + ) |
| 14 | +end |
| 15 | +Base.copy(event::LinuxPerf.EventType) = LinuxPerf.EventType(event.category, event.event) |
| 16 | + |
5 | 17 | mutable struct Trial |
6 | 18 | params::Parameters |
7 | 19 | times::Vector{Float64} |
@@ -40,7 +52,7 @@ function Base.copy(t::Trial) |
40 | 52 | copy(t.gctimes), |
41 | 53 | t.memory, |
42 | 54 | t.allocs, |
43 | | - nothing, # There is no copy method for LinuxPerf.Stats or LinuxPerf.ThreadStats |
| 55 | + isnothing(t.linux_perf_stats) ? nothing : copy(t.linux_perf_stats), |
44 | 56 | ) |
45 | 57 | end |
46 | 58 |
|
@@ -68,12 +80,18 @@ function Base.getindex(t::Trial, i::Number) |
68 | 80 | return push!( |
69 | 81 | Trial(t.params), |
70 | 82 | TrialContents( |
71 | | - t.times[i], t.gctimes[i], t.memory, t.allocs, nothing, nothing, nothing |
| 83 | + t.times[i], |
| 84 | + t.gctimes[i], |
| 85 | + t.memory, |
| 86 | + t.allocs, |
| 87 | + nothing, |
| 88 | + nothing, |
| 89 | + t.linux_perf_stats, |
72 | 90 | ), |
73 | 91 | ) |
74 | 92 | end |
75 | 93 | function Base.getindex(t::Trial, i) |
76 | | - return Trial(t.params, t.times[i], t.gctimes[i], t.memory, t.allocs, nothing) |
| 94 | + return Trial(t.params, t.times[i], t.gctimes[i], t.memory, t.allocs, t.linux_perf_stats) |
77 | 95 | end |
78 | 96 | Base.lastindex(t::Trial) = length(t) |
79 | 97 |
|
@@ -145,11 +163,18 @@ function Base.:(==)(a::TrialEstimate, b::TrialEstimate) |
145 | 163 | a.time == b.time && |
146 | 164 | a.gctime == b.gctime && |
147 | 165 | a.memory == b.memory && |
148 | | - a.allocs == b.allocs |
| 166 | + a.allocs == b.allocs |
149 | 167 | end |
150 | 168 |
|
151 | 169 | function Base.copy(t::TrialEstimate) |
152 | | - return TrialEstimate(copy(t.params), t.time, t.gctime, t.memory, t.allocs, t.linux_perf_stats) # TODO: copy linux_perf_stats |
| 170 | + return TrialEstimate( |
| 171 | + copy(t.params), |
| 172 | + t.time, |
| 173 | + t.gctime, |
| 174 | + t.memory, |
| 175 | + t.allocs, |
| 176 | + isnothing(t.linux_perf_stats) ? nothing : copy(t.linux_perf_stats), |
| 177 | + ) |
153 | 178 | end |
154 | 179 |
|
155 | 180 | function Base.minimum(trial::Trial) |
|
0 commit comments