-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix benchmarks and test them with PkgJogger (#107)
* Rename benchmark file * Use PkgJogger to test for benchmark breakage * Fix benchmark suite * Lighter test deps
- Loading branch information
Showing
10 changed files
with
71 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
[deps] | ||
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" | ||
ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f" | ||
DitherPunk = "b8f752a5-abd5-43b6-a55b-e75efda20de0" | ||
ImageCore = "a09fc81d-aa75-5fe9-8630-4744c3626534" | ||
ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1" | ||
PkgBenchmark = "32113eaa-f34f-5b0d-bd6c-c81e245fc73d" | ||
PkgJogger = "10150987-6cc1-4b76-abee-b1c1cbd91c01" | ||
TestImages = "5e47fb64-e119-507b-a336-dd2b206d9990" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using BenchmarkTools | ||
using DitherPunk | ||
using TestImages | ||
using ColorTypes: RGB | ||
|
||
on_CI = haskey(ENV, "GITHUB_ACTIONS") | ||
|
||
img_gray = testimage("fabio_gray_256") | ||
img_color = testimage("fabio_color_256") | ||
|
||
## Define color scheme | ||
white = RGB{Float32}(1, 1, 1) | ||
yellow = RGB{Float32}(1, 1, 0) | ||
green = RGB{Float32}(0, 0.5, 0) | ||
orange = RGB{Float32}(1, 0.5, 0) | ||
red = RGB{Float32}(1, 0, 0) | ||
blue = RGB{Float32}(0, 0, 1) | ||
cs = [white, yellow, green, orange, red, blue] | ||
|
||
# Use one representative algorithm of each type | ||
algs = Dict( | ||
"error diffusion" => FloydSteinberg(), | ||
"ordered dithering" => Bayer(3;), | ||
"closest color" => ClosestColor(), | ||
"threshold dithering" => WhiteNoiseThreshold(), | ||
) | ||
|
||
# Tag what is tested on each algorithm type | ||
suite = BenchmarkGroup() | ||
suite["error diffusion"] = BenchmarkGroup(["binary", "color"]) | ||
suite["ordered dithering"] = BenchmarkGroup(["binary", "color"]) | ||
suite["threshold dithering"] = BenchmarkGroup(["binary"]) | ||
suite["closest color"] = BenchmarkGroup(["binary", "color"]) | ||
|
||
println(suite) | ||
|
||
for (algname, alg) in algs | ||
suite[algname]["binary new"] = @benchmarkable dither($(img_gray), $(alg)) | ||
suite[algname]["binary inplace"] = @benchmarkable dither!($(copy(img_gray)), $(alg)) | ||
|
||
suite[algname]["per-channel new"] = @benchmarkable dither($(img_color), $(alg)) | ||
suite[algname]["per-channel inplace"] = @benchmarkable dither!( | ||
$(copy(img_color)), $(alg) | ||
) | ||
|
||
if "color" in suite[algname].tags | ||
suite[algname]["color new"] = @benchmarkable dither($(img_color), $(alg), $(cs)) | ||
suite[algname]["color inplace"] = @benchmarkable dither!( | ||
$(copy(img_color)), $(alg), $(cs) | ||
) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,5 @@ | ||
using BenchmarkTools | ||
using PkgJogger | ||
using DitherPunk | ||
using TestImages | ||
using ImageCore | ||
|
||
on_CI = haskey(ENV, "GITHUB_ACTIONS") | ||
|
||
img_gray = testimage("fabio_gray_256") | ||
img_color = testimage("fabio_color_256") | ||
|
||
## Define color scheme | ||
white = RGB{Float32}(1, 1, 1) | ||
yellow = RGB{Float32}(1, 1, 0) | ||
green = RGB{Float32}(0, 0.5, 0) | ||
orange = RGB{Float32}(1, 0.5, 0) | ||
red = RGB{Float32}(1, 0, 0) | ||
blue = RGB{Float32}(0, 0, 1) | ||
cs = [white, yellow, green, orange, red, blue] | ||
|
||
# Use one representative algorithm of each type | ||
algs = Dict( | ||
"error diffusion" => FloydSteinberg(), | ||
"ordered dithering" => Bayer(; level=3), | ||
"closest color" => ClosestColor(), | ||
"threshold dithering" => WhiteNoiseThreshold(), | ||
) | ||
|
||
# Tag what is tested on each algorithm type | ||
SUITE = BenchmarkGroup() | ||
SUITE["error diffusion"] = BenchmarkGroup(["binary", "color"]) | ||
SUITE["ordered dithering"] = BenchmarkGroup(["binary", "color"]) | ||
SUITE["threshold dithering"] = BenchmarkGroup(["binary"]) | ||
SUITE["closest color"] = BenchmarkGroup(["binary", "color"]) | ||
|
||
println(SUITE) | ||
|
||
for (algname, alg) in algs | ||
SUITE[algname]["binary new"] = @benchmarkable dither($(img_gray), $(alg)) | ||
SUITE[algname]["binary inplace"] = @benchmarkable dither!($(copy(img_gray)), $(alg)) | ||
|
||
SUITE[algname]["per-channel new"] = @benchmarkable dither($(img_color), $(alg)) | ||
SUITE[algname]["per-channel inplace"] = @benchmarkable dither!( | ||
$(copy(img_color)), $(alg) | ||
) | ||
|
||
if "color" in SUITE[algname].tags | ||
SUITE[algname]["color new"] = @benchmarkable dither($(img_color), $(alg), $(cs)) | ||
SUITE[algname]["color inplace"] = @benchmarkable dither!( | ||
$(copy(img_color)), $(alg), $(cs) | ||
) | ||
end | ||
end | ||
# Use PkgJogger.@jog to create the JogDitherPunk module | ||
@jog DitherPunk | ||
SUITE = JogDitherPunk.suite() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,14 @@ | ||
[deps] | ||
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" | ||
ColorSchemes = "35d6a980-a343-548e-a6ea-1d62b119f2f4" | ||
ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f" | ||
ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7" | ||
ImageBase = "c817782e-172a-44cc-b673-b171935fbb9e" | ||
ImageIO = "82e4d734-157c-48bb-816b-45c225c6df19" | ||
ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1" | ||
FixedPointNumbers = "53c48c17-4a7d-5ca2-90c5-79b7896eea93" | ||
IndirectArrays = "9b13fd28-a010-5f03-acff-a1bbcff69959" | ||
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b" | ||
JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899" | ||
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881" | ||
PkgJogger = "10150987-6cc1-4b76-abee-b1c1cbd91c01" | ||
ReferenceTests = "324d217c-45ce-50fc-942e-d289b448e8cf" | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
TestImages = "5e47fb64-e119-507b-a336-dd2b206d9990" | ||
|
||
[compat] | ||
Aqua = "0.8" | ||
ColorSchemes = "3" | ||
ImageBase = "0.1" | ||
ImageIO = "0.6" | ||
ImageMagick = "1" | ||
IndirectArrays = "0.5, 1.0" | ||
OffsetArrays = "1" | ||
ReferenceTests = "0.10.1" | ||
TestImages = "1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
using PkgJogger | ||
using DitherPunk | ||
|
||
PkgJogger.@test_benchmarks DitherPunk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
using DitherPunk | ||
using ImageBase: RGB, Gray | ||
using ColorTypes: RGB, Gray | ||
using Test | ||
using ReferenceTests | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
using DitherPunk | ||
using ImageBase | ||
using ColorTypes: RGB, HSV | ||
using ReferenceTests | ||
using TestImages | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters