diff --git a/tests/bench_masks.nim b/tests/bench_masks.nim index abf15de..c3f21c3 100644 --- a/tests/bench_masks.nim +++ b/tests/bench_masks.nim @@ -1,70 +1,71 @@ import benchy, pixie -let mask = newMask(2560, 1440) +block: + let mask = newMask(2560, 1440) -proc reset() = + proc reset() = + mask.fill(63) + + reset() + + timeIt "minifyBy2": + let minified = mask.minifyBy2() + doAssert minified[0, 0] == 63 + + reset() + + timeIt "magnifyBy2": + let magnified = mask.magnifyBy2() + doAssert magnified[0, 0] == 63 + + reset() + + timeIt "invert": + mask.invert() + + reset() + + timeIt "applyOpacity": + reset() + mask.applyOpacity(0.5) + + reset() + + timeIt "ceil": + mask.ceil() + +block: + let mask = newMask(400, 400) mask.fill(63) -reset() + timeIt "blur": + mask.blur(12) -timeIt "minifyBy2": - let minified = mask.minifyBy2() - doAssert minified[0, 0] == 63 + block spread_1: + let p = newPath() + p.rect(100, 100, 200, 200) -reset() + timeIt "spread_1": + mask.fill(0) + mask.fillPath(p) + mask.spread(5) -timeIt "magnifyBy2": - let magnified = mask.magnifyBy2() - doAssert magnified[0, 0] == 63 + block spread_2: + let p = newPath() + p.rect(100, 100, 200, 200) -reset() + timeIt "spread_2": + mask.fill(0) + mask.fillPath(p) + mask.spread(10) -timeIt "invert": - mask.invert() + block spread_3: + timeIt "spread_3": + mask.fill(255) + mask.spread(10) -reset() - -timeIt "applyOpacity": - reset() - mask.applyOpacity(0.5) - -reset() - -timeIt "blur": - mask.blur(40) - -reset() - -timeIt "ceil": - mask.ceil() - -reset() - -block spread_1: - let p = newPath() - p.rect(500, 500, 500, 500) - - timeIt "spread_1": - mask.fill(0) - mask.fillPath(p) - mask.spread(10) - -block spread_2: - let p = newPath() - p.rect(500, 500, 1000, 1000) - - timeIt "spread_2": - mask.fill(0) - mask.fillPath(p) - mask.spread(10) - -block spread_3: - timeIt "spread_3": - mask.fill(255) - mask.spread(10) - -block spread_4: - timeIt "spread_4": - mask.fill(0) - mask.unsafe[1000, 1000] = 255 - mask.spread(10) + block spread_4: + timeIt "spread_4": + mask.fill(0) + mask.unsafe[200, 200] = 255 + mask.spread(5)