Skip to content

Commit 088df33

Browse files
authored
Apply JuliaFormatter with BlueStyle and add it to tests (#327)
* Set up JuliaFormatter * Apply formatting with blue style * Add blue style badge * No JuliaFormatter on 1.0
1 parent b789f01 commit 088df33

19 files changed

+862
-478
lines changed

.JuliaFormatter.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
style = "blue"

BenchmarkPlots/src/BenchmarkPlots.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ using BenchmarkTools: Trial, BenchmarkGroup
77
legend --> false
88
yguide --> "t / ns"
99
xticks --> false
10-
t.times
10+
return t.times
1111
end
1212

1313
@recipe function f(g::BenchmarkGroup, keys=keys(g))

Project.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ julia = "1"
1616

1717
[extras]
1818
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
19+
JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
1920
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
2021
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2122

2223
[targets]
23-
test = ["Aqua", "Statistics", "Test"]
24+
test = ["Aqua", "JuliaFormatter", "Statistics", "Test"]

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
[![][docs-dev-img]][docs-dev-url]
1010
[![Build Status](https://github.com/JuliaCI/BenchmarkTools.jl/workflows/CI/badge.svg)](https://github.com/JuliaCI/BenchmarkTools.jl/actions/workflows/CI.yml?query=branch%3Amaster)
1111
[![Code Coverage](https://codecov.io/gh/JuliaCI/BenchmarkTools.jl/branch/master/graph/badge.svg?label=codecov&token=ccN7NZpkBx)](https://codecov.io/gh/JuliaCI/BenchmarkTools.jl)
12+
[![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle)
1213
[![Aqua QA](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl)
1314

1415
BenchmarkTools makes **performance tracking of Julia code easy** by supplying a framework for **writing and running groups of benchmarks** as well as **comparing benchmark results**.

benchmark/benchmarks.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ suite["dot"] = BenchmarkGroup(["broadcast", "elementwise"])
1313
teststr = join(rand(MersenneTwister(1), 'a':'d', 10^4))
1414

1515
# Add some benchmarks to the "string" group
16-
suite["string"]["replace"] = @benchmarkable replace($teststr, "a", "b") seconds=Float64(π)
17-
suite["string"]["join"] = @benchmarkable join($teststr, $teststr) samples=42
16+
suite["string"]["replace"] = @benchmarkable replace($teststr, "a", "b") seconds = Float64(π)
17+
suite["string"]["join"] = @benchmarkable join($teststr, $teststr) samples = 42
1818

1919
# Add some benchmarks to the "trig"/"dot" group
2020
for f in (sin, cos, tan)
@@ -30,8 +30,8 @@ end
3030
paramspath = joinpath(dirname(@__FILE__), "params.json")
3131

3232
if isfile(paramspath)
33-
loadparams!(suite, BenchmarkTools.load(paramspath)[1], :evals);
33+
loadparams!(suite, BenchmarkTools.load(paramspath)[1], :evals)
3434
else
3535
tune!(suite)
36-
BenchmarkTools.save(paramspath, params(suite));
36+
BenchmarkTools.save(paramspath, params(suite))
3737
end

docs/generate_logo.jl

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ JULIA_COLORS = [Luxor.julia_blue, Luxor.julia_green, Luxor.julia_red, Luxor.juli
88
function draw_logo(; path, dark=false)
99
Drawing(500, 500, path)
1010
origin()
11-
squircle(O, 250, 250, :clip, rt=0.3)
11+
squircle(O, 250, 250, :clip; rt=0.3)
1212
sethue(dark ? "black" : "white")
1313
paint()
1414

@@ -20,11 +20,14 @@ function draw_logo(; path, dark=false)
2020

2121
for n in 1:4
2222
setblend(blend(O - (240, 0), O + (240, 0), "white", JULIA_COLORS[n]))
23-
sector(O,
23+
sector(
24+
O,
2425
rescale(n, 1, 3, rmin, rmax),
2526
rescale(n, 1, 3, rmin, rmax) + band,
26-
3π / 2 - deg2rad(45), 3π / 2 + deg2rad(45),
27-
:fill)
27+
3π / 2 - deg2rad(45),
28+
3π / 2 + deg2rad(45),
29+
:fill,
30+
)
2831
end
2932

3033
sethue(dark ? "black" : "white")
@@ -37,8 +40,8 @@ function draw_logo(; path, dark=false)
3740
end
3841

3942
finish()
40-
preview()
43+
return preview()
4144
end
4245

43-
draw_logo(path=joinpath(@__DIR__, "src", "assets", "logo.svg"), dark=false)
44-
draw_logo(path=joinpath(@__DIR__, "src", "assets", "logo-dark.svg"), dark=true)
46+
draw_logo(; path=joinpath(@__DIR__, "src", "assets", "logo.svg"), dark=false)
47+
draw_logo(; path=joinpath(@__DIR__, "src", "assets", "logo-dark.svg"), dark=true)

docs/make.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,4 @@ makedocs(;
2121
],
2222
)
2323

24-
deploydocs(;
25-
repo="github.com/JuliaCI/BenchmarkTools.jl",
26-
)
24+
deploydocs(; repo="github.com/JuliaCI/BenchmarkTools.jl")

src/BenchmarkTools.jl

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ using UUIDs: uuid4
99
using Printf
1010
using Profile
1111

12-
1312
const BENCHMARKTOOLS_VERSION = v"1.0.0"
1413

1514
##############
@@ -27,19 +26,19 @@ export loadparams!
2726
include("trials.jl")
2827

2928
export gctime,
30-
memory,
31-
allocs,
32-
params,
33-
ratio,
34-
judge,
35-
isinvariant,
36-
isregression,
37-
isimprovement,
38-
median,
39-
mean,
40-
rmskew!,
41-
rmskew,
42-
trim
29+
memory,
30+
allocs,
31+
params,
32+
ratio,
33+
judge,
34+
isinvariant,
35+
isregression,
36+
isimprovement,
37+
median,
38+
mean,
39+
rmskew!,
40+
rmskew,
41+
trim
4342

4443
##################
4544
# Benchmark Data #
@@ -48,30 +47,23 @@ export gctime,
4847
include("groups.jl")
4948

5049
export BenchmarkGroup,
51-
invariants,
52-
regressions,
53-
improvements,
54-
@tagged,
55-
addgroup!,
56-
leaves,
57-
@benchmarkset,
58-
@case,
59-
clear_empty!
50+
invariants,
51+
regressions,
52+
improvements,
53+
@tagged,
54+
addgroup!,
55+
leaves,
56+
@benchmarkset,
57+
@case,
58+
clear_empty!
6059

6160
######################
6261
# Execution Strategy #
6362
######################
6463

6564
include("execution.jl")
6665

67-
export tune!,
68-
warmup,
69-
@ballocated,
70-
@benchmark,
71-
@benchmarkable,
72-
@belapsed,
73-
@btime,
74-
@bprofile
66+
export tune!, warmup, @ballocated, @benchmark, @benchmarkable, @belapsed, @btime, @bprofile
7567

7668
#################
7769
# Serialization #

0 commit comments

Comments
 (0)