Skip to content

Commit 03bcbc7

Browse files
author
Andrey Oskin
committed
singlethread kmeans
1 parent 3961ca4 commit 03bcbc7

File tree

10 files changed

+393
-1
lines changed

10 files changed

+393
-1
lines changed

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ uuid = "42b8e9d4-006b-409a-8472-7f34b3fb58af"
33
authors = ["Andrey Oskin"]
44
version = "0.1.0"
55

6+
[deps]
7+
68
[compat]
79
julia = "1.3"
810

benchmark/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[deps]

benchmark/README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Local scripts usage
2+
3+
This mode is useful when multiple changes are being made and one do not want to generate multiple commits per branch.
4+
5+
## Single benchmark
6+
To run benchmarks locally
7+
8+
```julia
9+
julia runbenchmarks.jl
10+
```
11+
12+
To see the results of the last benchmark
13+
```julia
14+
julia pprintresult.jl | less
15+
```
16+
17+
To see the results of previous run
18+
```julia
19+
julia pprintresult.jl results/20200101T010101.json | less
20+
```
21+
22+
## Judge
23+
One may compare results of two runs with the following command
24+
25+
```julia
26+
julia pprintjudge.jl results/20200102T000000.json results/20200101T0000000.json
27+
```
28+
here first argument is target, second is baseline
29+
30+
Without any arguments `pprintjudge` generates comparison of two the last two runs or
31+
comparison of last run with the last baseline run if it exists. To generate baseline run
32+
use the following
33+
34+
```julia
35+
julia runbenchmarks.jl -b # creates file of the form results/20200101T000000-baseline.json
36+
```
37+
38+
All other runs will be compared to this file.
39+
40+
# BenchmarkCI
41+
42+
This mode is useful to compare different branches or for automated benchmarking.
43+
44+
Detailed information regarding running BenchmarkCI can be found in [BenchmarkCI](https://github.com/tkf/BenchmarkCI.jl) documentation.
45+
46+
Following commands will generate benchmark report that compares current commit with "origin/master"
47+
```julia
48+
shell> cd ~/.julia/dev/MyProject/
49+
50+
julia> using BenchmarkCI
51+
52+
julia> BenchmarkCI.judge()
53+
...
54+
55+
julia> BenchmarkCI.displayjudgement()
56+
```
57+
58+
If one need to run benchmark against local master, than instead of `BenchmarkCI.judge()` one should
59+
use `BenchmarkCI.judge(baseline="master")`

benchmark/benchmarks.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Taken from: https://github.com/tkf/Transducers.jl/tree/master/benchmark
2+
if lowercase(get(ENV, "CI", "false")) == "true"
3+
@info "Executing in CI. Instantiating benchmark environment..."
4+
using Pkg
5+
Pkg.activate(@__DIR__)
6+
Pkg.instantiate()
7+
end
8+
9+
using BenchmarkTools
10+
const SUITE = BenchmarkGroup()
11+
for file in sort([file for file in readdir(@__DIR__) if occursin(r"bench[_0-9]+(.*).jl", file)])
12+
m = match(r"bench[_0-9]+(.*).jl", file)
13+
14+
SUITE[m[1]] = include(file)
15+
end

benchmark/pprinthelper.jl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using PkgBenchmark
2+
using Markdown
3+
4+
function displayresult(result)
5+
md = sprint(export_markdown, result)
6+
md = replace(md, ":x:" => "")
7+
md = replace(md, ":white_check_mark:" => "")
8+
display(Markdown.parse(md))
9+
end
10+
11+
function printnewsection(name)
12+
println()
13+
println()
14+
println()
15+
printstyled("" ^ displaysize(stdout)[2]; color=:blue)
16+
println()
17+
printstyled(name; bold=true)
18+
println()
19+
println()
20+
end

benchmark/pprintjudge.jl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using PkgBenchmark
2+
include("pprinthelper.jl")
3+
4+
if length(ARGS) == 2
5+
group_target = PkgBenchmark.readresults(ARGS[1])
6+
group_baseline = PkgBenchmark.readresults(ARGS[2])
7+
else
8+
res_dir = joinpath(@__DIR__, "results")
9+
last_result = maximum(filter(x -> x != ".gitignore", readdir(res_dir)))
10+
baselines = filter(x -> (x != ".gitignore") & occursin("baseline", x), readdir(res_dir))
11+
last_baseline = isempty(baselines) ? maximum(filter(x -> (x != ".gitignore") & (x != last_result), readdir(res_dir))) : maximum(baselines)
12+
group_target = PkgBenchmark.readresults(joinpath(res_dir, last_result))
13+
group_baseline = PkgBenchmark.readresults(joinpath(res_dir, last_baseline))
14+
end
15+
judgement = judge(group_target, group_baseline)
16+
17+
displayresult(judgement)
18+
19+
printnewsection("Target result")
20+
displayresult(group_target)
21+
22+
printnewsection("Baseline result")
23+
displayresult(group_baseline)

benchmark/pprintresult.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using PkgBenchmark
2+
include("pprinthelper.jl")
3+
4+
if length(ARGS) == 1
5+
result = PkgBenchmark.readresults(ARGS[1])
6+
elseif length(ARGS) == 0
7+
res_dir = joinpath(@__DIR__, "results")
8+
path = maximum(readdir(res_dir))
9+
path = joinpath(res_dir, path)
10+
result = PkgBenchmark.readresults(path)
11+
end
12+
13+
displayresult(result)

benchmark/results/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.json

benchmark/runbenchmarks.jl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using PkgBenchmark
2+
using Dates
3+
4+
if (length(ARGS) == 1) && (ARGS[1] == "-b")
5+
path = joinpath(@__DIR__, "results", "$(Dates.format(now(), dateformat"yyyymmddTHHMMSS"))-baseline.json")
6+
else
7+
path = joinpath(@__DIR__, "results", "$(Dates.format(now(), dateformat"yyyymmddTHHMMSS")).json")
8+
end
9+
10+
benchmarkpkg(
11+
dirname(@__DIR__),
12+
BenchmarkConfig(
13+
env = Dict(
14+
"JULIA_NUM_THREADS" => "1",
15+
"OMP_NUM_THREADS" => "1",
16+
),
17+
),
18+
resultfile = path,
19+
)

0 commit comments

Comments
 (0)