Mercurial > repos > public > sbplib_julia
comparison benchmark/run_and_view.jl @ 1190:1aca445216b8 tooling/benchmarks
Clean up todos
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Fri, 27 Jan 2023 12:40:01 +0100 |
parents | 525015283843 |
children | 12b525cd3da6 |
comparison
equal
deleted
inserted
replaced
1189:525015283843 | 1190:1aca445216b8 |
---|---|
19 r = run_benchmark(args...; kwargs...) | 19 r = run_benchmark(args...; kwargs...) |
20 file_path = write_result_html(r) | 20 file_path = write_result_html(r) |
21 open_in_default_browser(file_path) | 21 open_in_default_browser(file_path) |
22 end | 22 end |
23 | 23 |
24 # TBD: What parts are PkgBenchmark contributing? Can it be stripped out? Can we replace the html output part? | |
25 | 24 |
26 """ | 25 """ |
27 run_benchmark() | 26 run_benchmark() |
28 | 27 |
29 Runs the benchmark suite for the current working directory and returns a `PkgBenchmark.BenchmarkResult` | 28 Runs the benchmark suite for the current working directory and returns a `PkgBenchmark.BenchmarkResult` |
39 """ | 38 """ |
40 run_benchmark(rev) | 39 run_benchmark(rev) |
41 | 40 |
42 Updates the repository to the given revison and runs the benchmark suite. When done, updates the repository to the origianl state. | 41 Updates the repository to the given revison and runs the benchmark suite. When done, updates the repository to the origianl state. |
43 `rev` can be any identifier compatible with `hg update`. | 42 `rev` can be any identifier compatible with `hg update`. |
44 | |
45 | 43 |
46 Returns a `PkgBenchmark.BenchmarkResult` | 44 Returns a `PkgBenchmark.BenchmarkResult` |
47 """ | 45 """ |
48 function run_benchmark(rev) | 46 function run_benchmark(rev) |
49 rev_before = hg_rev() | 47 rev_before = hg_rev() |
73 hg_update(rev_before) | 71 hg_update(rev_before) |
74 | 72 |
75 return PkgBenchmark.judge(t,b,f; judgekwargs...) | 73 return PkgBenchmark.judge(t,b,f; judgekwargs...) |
76 end | 74 end |
77 | 75 |
78 # TBD: How to compare against current working directory? Possible to create a temporary commit? | |
79 | |
80 | 76 |
81 function add_rev_info(benchmarkresult, rev) | 77 function add_rev_info(benchmarkresult, rev) |
82 return PkgBenchmark.BenchmarkResults( | 78 return PkgBenchmark.BenchmarkResults( |
83 benchmarkresult.name, | 79 benchmarkresult.name, |
84 rev, | 80 rev, |
88 benchmarkresult.vinfo, | 84 benchmarkresult.vinfo, |
89 benchmarkresult.benchmarkconfig, | 85 benchmarkresult.benchmarkconfig, |
90 ) | 86 ) |
91 end | 87 end |
92 | 88 |
89 | |
93 function write_result_html(io, r) | 90 function write_result_html(io, r) |
94 iobuffer = IOBuffer() | 91 iobuffer = IOBuffer() |
95 PkgBenchmark.export_markdown(iobuffer, r) | 92 PkgBenchmark.export_markdown(iobuffer, r) |
96 | 93 |
97 parsed_md = Markdown.parse(String(take!(iobuffer))) | 94 parsed_md = Markdown.parse(String(take!(iobuffer))) |
100 template = Mustache.load(template_path) | 97 template = Mustache.load(template_path) |
101 | 98 |
102 dt = Dates.format(PkgBenchmark.date(r), "yyyy-mm-dd HH:MM:SS") | 99 dt = Dates.format(PkgBenchmark.date(r), "yyyy-mm-dd HH:MM:SS") |
103 Mustache.render(io, template, Dict("title"=>dt, "content"=>content)) | 100 Mustache.render(io, template, Dict("title"=>dt, "content"=>content)) |
104 end | 101 end |
105 ## Fix the writing of the commit, it chops off all the important info | |
106 | 102 |
107 function write_result_html(r) | 103 function write_result_html(r) |
108 dt = Dates.format(PkgBenchmark.date(r), "yyyy-mm-dd HHMMSS") | 104 dt = Dates.format(PkgBenchmark.date(r), "yyyy-mm-dd HHMMSS") |
109 file_path = joinpath(results_dir, dt*".html") | 105 file_path = joinpath(results_dir, dt*".html") |
110 | 106 |
113 end | 109 end |
114 | 110 |
115 return file_path | 111 return file_path |
116 end | 112 end |
117 | 113 |
114 | |
118 PkgBenchmark.date(j::PkgBenchmark.BenchmarkJudgement) = PkgBenchmark.date(PkgBenchmark.target_result(j)) | 115 PkgBenchmark.date(j::PkgBenchmark.BenchmarkJudgement) = PkgBenchmark.date(PkgBenchmark.target_result(j)) |
116 | |
119 | 117 |
120 function hg_id() | 118 function hg_id() |
121 cmd = Cmd(`hg id`, dir=sbplib_root) | 119 cmd = Cmd(`hg id`, dir=sbplib_root) |
122 return readchomp(addenv(cmd, "HGPLAIN"=>"")) | 120 return readchomp(addenv(cmd, "HGPLAIN"=>"")) |
123 end | 121 end |
129 | 127 |
130 function hg_update(rev) | 128 function hg_update(rev) |
131 cmd = Cmd(`hg update --check -r $rev`, dir=sbplib_root) | 129 cmd = Cmd(`hg update --check -r $rev`, dir=sbplib_root) |
132 run(addenv(cmd, "HGPLAIN"=>"")) | 130 run(addenv(cmd, "HGPLAIN"=>"")) |
133 end | 131 end |
132 | |
134 | 133 |
135 # From Pluto.jl/src/webserver/WebServer.jl (2023-01-24) | 134 # From Pluto.jl/src/webserver/WebServer.jl (2023-01-24) |
136 function open_in_default_browser(url::AbstractString)::Bool | 135 function open_in_default_browser(url::AbstractString)::Bool |
137 try | 136 try |
138 if Sys.isapple() | 137 if Sys.isapple() |
150 catch ex | 149 catch ex |
151 false | 150 false |
152 end | 151 end |
153 end | 152 end |
154 | 153 |
154 | |
155 main | 155 main |
156 | 156 |
157 # TODO: Change color of codeblocks | 157 # TODO: Better logging of what is happening |
158 # TODO: Change width of tables and code blocks | 158 |
159 # TODO: Clean up the HTML output? | |
160 # TODO: Make the codeblocks in the table look nicer | |
161 # TODO: Change width of tables and code blocks so everything is visible | |
162 # TODO: Fix the commit id, it chops off all the important info | |
163 # TODO: Make title less verbose | |
164 # TBD: Do we have to replace export_markdown? Could use a template instead. | |
165 | |
166 | |
167 # TBD: How to compare against current working directory? Possible to create a temporary commit? | |
168 # TBD: What parts are PkgBenchmark contributing? Can it be stripped out? |