Mercurial > repos > public > sbplib_julia
comparison benchmark/run_and_view.jl @ 1172:34446df5733f tooling/benchmarks
Add run_and_view script
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Wed, 25 Jan 2023 12:52:09 +0100 |
parents | |
children | 50c31500eb97 |
comparison
equal
deleted
inserted
replaced
1171:87bc91def1ff | 1172:34446df5733f |
---|---|
1 using PkgBenchmark | |
2 using Markdown | |
3 using Mustache | |
4 | |
5 import Sbplib | |
6 | |
7 # From Pluto.jl/src/webserver/WebServer.jl (2023-01-24) | |
8 function open_in_default_browser(url::AbstractString)::Bool | |
9 try | |
10 if Sys.isapple() | |
11 Base.run(`open $url`) | |
12 true | |
13 elseif Sys.iswindows() || detectwsl() | |
14 Base.run(`powershell.exe Start "'$url'"`) | |
15 true | |
16 elseif Sys.islinux() | |
17 Base.run(`xdg-open $url`) | |
18 true | |
19 else | |
20 false | |
21 end | |
22 catch ex | |
23 false | |
24 end | |
25 end | |
26 | |
27 r = benchmarkpkg(Sbplib) | |
28 | |
29 iobuffer = IOBuffer() | |
30 export_markdown(iobuffer, r) | |
31 | |
32 parsed_md = Markdown.parse(String(take!(iobuffer))) | |
33 | |
34 sbplib_root = splitpath(pathof(Sbplib))[1:end-2] |> joinpath | |
35 | |
36 results_dir = mkpath(joinpath(sbplib_root, "benchmark/results")) | |
37 | |
38 dt = Dates.format(now(), "yyyy-mm-dd HH:MM:SS") | |
39 | |
40 file_path = joinpath(results_dir, dt*".html") | |
41 | |
42 | |
43 template = Mustache.load(joinpath(sbplib_root, "benchmark/result.tmpl")) | |
44 | |
45 open(file_path, "w") do io | |
46 content = html(parsed_md) | |
47 Mustache.render(io, template, Dict("title"=>dt, "content"=>content)) | |
48 # html(io, parsed_md) | |
49 end | |
50 | |
51 open_in_default_browser(file_path) | |
52 | |
53 | |
54 # TODO: Cleanup code | |
55 # TODO: Change color of codeblocks | |
56 # TODO: Change width of tables and code blocks |