comparison benchmark/benchmark_utils.jl @ 1726:471a948cd2b2 rename_module

Rename project from Sbplib to Diffinitive
author Vidar Stiernström <vidar.stiernstrom@gmail.com>
date Sat, 07 Sep 2024 12:11:53 -0700
parents 5193e6cd6c6a
children e1d64f4110bd
comparison
equal deleted inserted replaced
1725:8317252e4535 1726:471a948cd2b2
1 import PkgBenchmark 1 import PkgBenchmark
2 import Markdown 2 import Markdown
3 import Mustache 3 import Mustache
4 import Dates 4 import Dates
5 5
6 import Sbplib 6 import Diffinitive
7 7
8 const sbplib_root = splitpath(pathof(Sbplib))[1:end-2] |> joinpath 8 const diffinitive_root = splitpath(pathof(Diffinitive))[1:end-2] |> joinpath
9 const results_dir = mkpath(joinpath(sbplib_root, "benchmark/results")) 9 const results_dir = mkpath(joinpath(diffinitive_root, "benchmark/results"))
10 const template_path = joinpath(sbplib_root, "benchmark/result.tmpl") 10 const template_path = joinpath(diffinitive_root, "benchmark/result.tmpl")
11 11
12 """ 12 """
13 mainmain(;rev=nothing, target=nothing, baseline=nothing , kwargs...) 13 mainmain(;rev=nothing, target=nothing, baseline=nothing , kwargs...)
14 14
15 Calls `run_benchmark(args...; kwargs...)` and writes the results as an HTML 15 Calls `run_benchmark(args...; kwargs...)` and writes the results as an HTML
47 47
48 Run the benchmark suite for the current working directory and return a 48 Run the benchmark suite for the current working directory and return a
49 `PkgBenchmark.BenchmarkResult` 49 `PkgBenchmark.BenchmarkResult`
50 """ 50 """
51 function run_benchmark(;kwargs...) 51 function run_benchmark(;kwargs...)
52 r = PkgBenchmark.benchmarkpkg(Sbplib; kwargs...) 52 r = PkgBenchmark.benchmarkpkg(Diffinitive; kwargs...)
53 53
54 rev = hg_rev() # Should be changed to hg_id() when the html can handle it. 54 rev = hg_rev() # Should be changed to hg_id() when the html can handle it.
55 55
56 return add_rev_info(r, rev) 56 return add_rev_info(r, rev)
57 end 57 end
156 156
157 PkgBenchmark.date(j::PkgBenchmark.BenchmarkJudgement) = PkgBenchmark.date(PkgBenchmark.target_result(j)) 157 PkgBenchmark.date(j::PkgBenchmark.BenchmarkJudgement) = PkgBenchmark.date(PkgBenchmark.target_result(j))
158 158
159 159
160 function hg_id() 160 function hg_id()
161 cmd = Cmd(`hg id`, dir=sbplib_root) 161 cmd = Cmd(`hg id`, dir=diffinitive_root)
162 return readchomp(addenv(cmd, "HGPLAIN"=>"")) 162 return readchomp(addenv(cmd, "HGPLAIN"=>""))
163 end 163 end
164 164
165 function hg_rev() 165 function hg_rev()
166 cmd = Cmd(`hg id -i`, dir=sbplib_root) 166 cmd = Cmd(`hg id -i`, dir=diffinitive_root)
167 return readchomp(addenv(cmd, "HGPLAIN"=>"")) 167 return readchomp(addenv(cmd, "HGPLAIN"=>""))
168 end 168 end
169 169
170 function hg_update(rev) 170 function hg_update(rev)
171 cmd = Cmd(`hg update --check -r $rev`, dir=sbplib_root) 171 cmd = Cmd(`hg update --check -r $rev`, dir=diffinitive_root)
172 run(addenv(cmd, "HGPLAIN"=>"")) 172 run(addenv(cmd, "HGPLAIN"=>""))
173 173
174 return nothing 174 return nothing
175 end 175 end
176 176
180 Make a hg commit with the provided message. If `secret` is true the commit is 180 Make a hg commit with the provided message. If `secret` is true the commit is
181 in the secret phase stopping it from being pushed. 181 in the secret phase stopping it from being pushed.
182 """ 182 """
183 function hg_commit(msg; secret=false) 183 function hg_commit(msg; secret=false)
184 if secret 184 if secret
185 cmd = Cmd(`hg commit --verbose --secret --message $msg`, dir=sbplib_root) 185 cmd = Cmd(`hg commit --verbose --secret --message $msg`, dir=diffinitive_root)
186 else 186 else
187 cmd = Cmd(`hg commit --verbose --message $msg`, dir=sbplib_root) 187 cmd = Cmd(`hg commit --verbose --message $msg`, dir=diffinitive_root)
188 end 188 end
189 189
190 out = readchomp(addenv(cmd, "HGPLAIN"=>"")) 190 out = readchomp(addenv(cmd, "HGPLAIN"=>""))
191 191
192 return only(match(r"committed changeset \d+:([0-9a-z]+)", out)) 192 return only(match(r"committed changeset \d+:([0-9a-z]+)", out))
198 Strips the given commit from the repo. If `keep` is true, the changes of the 198 Strips the given commit from the repo. If `keep` is true, the changes of the
199 commit are kept in the working directory. 199 commit are kept in the working directory.
200 """ 200 """
201 function hg_strip(rev; keep=false) 201 function hg_strip(rev; keep=false)
202 if keep 202 if keep
203 cmd = Cmd(`hg --config extensions.strip= strip --keep -r $rev`, dir=sbplib_root) 203 cmd = Cmd(`hg --config extensions.strip= strip --keep -r $rev`, dir=diffinitive_root)
204 else 204 else
205 cmd = Cmd(`hg --config extensions.strip= strip -r $rev`, dir=sbplib_root) 205 cmd = Cmd(`hg --config extensions.strip= strip -r $rev`, dir=diffinitive_root)
206 end 206 end
207 207
208 run(addenv(cmd, "HGPLAIN"=>"")) 208 run(addenv(cmd, "HGPLAIN"=>""))
209 209
210 return nothing 210 return nothing
214 hg_is_dirty() 214 hg_is_dirty()
215 215
216 Return true if the repositopry has uncommited changes. 216 Return true if the repositopry has uncommited changes.
217 """ 217 """
218 function hg_is_dirty() 218 function hg_is_dirty()
219 cmd = Cmd(`hg identify --id`, dir=sbplib_root) 219 cmd = Cmd(`hg identify --id`, dir=diffinitive_root)
220 out = readchomp(addenv(cmd, "HGPLAIN"=>"")) 220 out = readchomp(addenv(cmd, "HGPLAIN"=>""))
221 221
222 return endswith(out, "+") 222 return endswith(out, "+")
223 end 223 end
224 224