commit
6ec1db5a81
1 changed files with 229 additions and 93 deletions
|
@ -1,185 +1,321 @@
|
|||
import benchy, chroma, vmath
|
||||
import benchy, chroma, vmath, pixie/images
|
||||
|
||||
include pixie/blends
|
||||
|
||||
const iterations = 1_000_000
|
||||
|
||||
let
|
||||
a = rgba(100, 200, 100, 255)
|
||||
b = rgba(25, 33, 100, 127)
|
||||
backdrop = newImage(256, 256)
|
||||
source = newImage(256, 256)
|
||||
source.fill(rgba(100, 100, 100, 100))
|
||||
|
||||
template reset() =
|
||||
backdrop.fill(rgba(0, 0, 0, 255))
|
||||
|
||||
reset()
|
||||
|
||||
timeIt "blendNormal":
|
||||
for i in 0 ..< iterations:
|
||||
keep blendNormal(a, b)
|
||||
for i in 0 ..< backdrop.data.len:
|
||||
backdrop.data[i] = blendNormal(backdrop.data[i], source.data[i])
|
||||
|
||||
reset()
|
||||
|
||||
timeIt "blendNormalFloats":
|
||||
for i in 0 ..< iterations:
|
||||
keep blendNormalFloats(a.color, b.color).rgba
|
||||
for i in 0 ..< backdrop.data.len:
|
||||
backdrop.data[i] = blendNormalFloats(
|
||||
backdrop.data[i].color, source.data[i].color
|
||||
).rgba
|
||||
|
||||
reset()
|
||||
|
||||
timeIt "blendDarken":
|
||||
for i in 0 ..< iterations:
|
||||
keep blendDarken(a, b)
|
||||
for i in 0 ..< backdrop.data.len:
|
||||
backdrop.data[i] = blendDarken(backdrop.data[i], source.data[i])
|
||||
|
||||
reset()
|
||||
|
||||
timeIt "blendDarkenFloats":
|
||||
for i in 0 ..< iterations:
|
||||
keep blendDarkenFloats(a.color, b.color).rgba
|
||||
for i in 0 ..< backdrop.data.len:
|
||||
backdrop.data[i] = blendDarkenFloats(
|
||||
backdrop.data[i].color, source.data[i].color
|
||||
).rgba
|
||||
|
||||
reset()
|
||||
|
||||
timeIt "blendMultiply":
|
||||
for i in 0 ..< iterations:
|
||||
keep blendMultiply(a, b)
|
||||
for i in 0 ..< backdrop.data.len:
|
||||
backdrop.data[i] = blendMultiply(backdrop.data[i], source.data[i])
|
||||
|
||||
reset()
|
||||
|
||||
timeIt "blendMultiplyFloats":
|
||||
for i in 0 ..< iterations:
|
||||
keep blendMultiplyFloats(a.color, b.color).rgba
|
||||
for i in 0 ..< backdrop.data.len:
|
||||
backdrop.data[i] = blendMultiplyFloats(
|
||||
backdrop.data[i].color, source.data[i].color
|
||||
).rgba
|
||||
|
||||
reset()
|
||||
|
||||
timeIt "blendLinearBurn":
|
||||
for i in 0 ..< iterations:
|
||||
keep blendLinearBurn(a, b)
|
||||
for i in 0 ..< backdrop.data.len:
|
||||
backdrop.data[i] = blendLinearBurn(backdrop.data[i], source.data[i])
|
||||
|
||||
reset()
|
||||
|
||||
timeIt "blendLinearBurnFloats":
|
||||
for i in 0 ..< iterations:
|
||||
keep blendLinearBurnFloats(a.color, b.color).rgba
|
||||
for i in 0 ..< backdrop.data.len:
|
||||
backdrop.data[i] = blendLinearBurnFloats(
|
||||
backdrop.data[i].color, source.data[i].color
|
||||
).rgba
|
||||
|
||||
reset()
|
||||
|
||||
timeIt "blendColorBurn":
|
||||
for i in 0 ..< iterations:
|
||||
keep blendColorBurn(a, b)
|
||||
for i in 0 ..< backdrop.data.len:
|
||||
backdrop.data[i] = blendColorBurn(backdrop.data[i], source.data[i])
|
||||
|
||||
reset()
|
||||
|
||||
timeIt "blendColorBurnFloats":
|
||||
for i in 0 ..< iterations:
|
||||
keep blendColorBurnFloats(a.color, b.color).rgba
|
||||
for i in 0 ..< backdrop.data.len:
|
||||
backdrop.data[i] = blendColorBurnFloats(
|
||||
backdrop.data[i].color, source.data[i].color
|
||||
).rgba
|
||||
|
||||
reset()
|
||||
|
||||
timeIt "blendLighten":
|
||||
for i in 0 ..< iterations:
|
||||
keep blendLighten(a, b)
|
||||
for i in 0 ..< backdrop.data.len:
|
||||
backdrop.data[i] = blendLighten(backdrop.data[i], source.data[i])
|
||||
|
||||
reset()
|
||||
|
||||
timeIt "blendLightenFloats":
|
||||
for i in 0 ..< iterations:
|
||||
keep blendLightenFloats(a.color, b.color).rgba
|
||||
for i in 0 ..< backdrop.data.len:
|
||||
backdrop.data[i] = blendLightenFloats(
|
||||
backdrop.data[i].color, source.data[i].color
|
||||
).rgba
|
||||
|
||||
reset()
|
||||
|
||||
timeIt "blendScreen":
|
||||
for i in 0 ..< iterations:
|
||||
keep blendScreen(a, b)
|
||||
for i in 0 ..< backdrop.data.len:
|
||||
backdrop.data[i] = blendScreen(backdrop.data[i], source.data[i])
|
||||
|
||||
reset()
|
||||
|
||||
timeIt "blendScreenFloats":
|
||||
for i in 0 ..< iterations:
|
||||
keep blendScreenFloats(a.color, b.color).rgba
|
||||
for i in 0 ..< backdrop.data.len:
|
||||
backdrop.data[i] = blendScreenFloats(
|
||||
backdrop.data[i].color, source.data[i].color
|
||||
).rgba
|
||||
|
||||
reset()
|
||||
|
||||
timeIt "blendLinearDodge":
|
||||
for i in 0 ..< iterations:
|
||||
keep blendLinearDodge(a, b)
|
||||
for i in 0 ..< backdrop.data.len:
|
||||
backdrop.data[i] = blendLinearDodge(backdrop.data[i], source.data[i])
|
||||
|
||||
reset()
|
||||
|
||||
timeIt "blendLinearDodgeFloats":
|
||||
for i in 0 ..< iterations:
|
||||
keep blendLinearDodgeFloats(a.color, b.color).rgba
|
||||
for i in 0 ..< backdrop.data.len:
|
||||
backdrop.data[i] = blendLinearDodgeFloats(
|
||||
backdrop.data[i].color, source.data[i].color
|
||||
).rgba
|
||||
|
||||
reset()
|
||||
|
||||
timeIt "blendColorDodge":
|
||||
for i in 0 ..< iterations:
|
||||
keep blendColorDodge(a, b)
|
||||
for i in 0 ..< backdrop.data.len:
|
||||
backdrop.data[i] = blendColorDodge(backdrop.data[i], source.data[i])
|
||||
|
||||
reset()
|
||||
|
||||
timeIt "blendColorDodgeFloats":
|
||||
for i in 0 ..< iterations:
|
||||
keep blendColorDodgeFloats(a.color, b.color).rgba
|
||||
for i in 0 ..< backdrop.data.len:
|
||||
backdrop.data[i] = blendColorDodgeFloats(
|
||||
backdrop.data[i].color, source.data[i].color
|
||||
).rgba
|
||||
|
||||
reset()
|
||||
|
||||
timeIt "blendOverlay":
|
||||
for i in 0 ..< iterations:
|
||||
keep blendOverlay(a, b)
|
||||
for i in 0 ..< backdrop.data.len:
|
||||
backdrop.data[i] = blendOverlay(backdrop.data[i], source.data[i])
|
||||
|
||||
reset()
|
||||
|
||||
timeIt "blendOverlayFloats":
|
||||
for i in 0 ..< iterations:
|
||||
keep blendOverlayFloats(a.color, b.color).rgba
|
||||
for i in 0 ..< backdrop.data.len:
|
||||
backdrop.data[i] = blendOverlayFloats(
|
||||
backdrop.data[i].color, source.data[i].color
|
||||
).rgba
|
||||
|
||||
reset()
|
||||
|
||||
timeIt "blendSoftLight":
|
||||
for i in 0 ..< iterations:
|
||||
keep blendSoftLight(a, b)
|
||||
for i in 0 ..< backdrop.data.len:
|
||||
backdrop.data[i] = blendSoftLight(backdrop.data[i], source.data[i])
|
||||
|
||||
reset()
|
||||
|
||||
timeIt "blendSoftLightFloats":
|
||||
for i in 0 ..< iterations:
|
||||
keep blendSoftLightFloats(a.color, b.color).rgba
|
||||
for i in 0 ..< backdrop.data.len:
|
||||
backdrop.data[i] = blendSoftLightFloats(
|
||||
backdrop.data[i].color, source.data[i].color
|
||||
).rgba
|
||||
|
||||
reset()
|
||||
|
||||
timeIt "blendHardLight":
|
||||
for i in 0 ..< iterations:
|
||||
keep blendHardLight(a, b)
|
||||
for i in 0 ..< backdrop.data.len:
|
||||
backdrop.data[i] = blendHardLight(backdrop.data[i], source.data[i])
|
||||
|
||||
reset()
|
||||
|
||||
timeIt "blendHardLightFloats":
|
||||
for i in 0 ..< iterations:
|
||||
keep blendHardLightFloats(a.color, b.color).rgba
|
||||
for i in 0 ..< backdrop.data.len:
|
||||
backdrop.data[i] = blendHardLightFloats(
|
||||
backdrop.data[i].color, source.data[i].color
|
||||
).rgba
|
||||
|
||||
reset()
|
||||
|
||||
timeIt "blendDifference":
|
||||
for i in 0 ..< iterations:
|
||||
keep blendDifference(a, b)
|
||||
for i in 0 ..< backdrop.data.len:
|
||||
backdrop.data[i] = blendDifference(backdrop.data[i], source.data[i])
|
||||
|
||||
reset()
|
||||
|
||||
timeIt "blendDifferenceFloats":
|
||||
for i in 0 ..< iterations:
|
||||
keep blendDifferenceFloats(a.color, b.color).rgba
|
||||
for i in 0 ..< backdrop.data.len:
|
||||
backdrop.data[i] = blendDifferenceFloats(
|
||||
backdrop.data[i].color, source.data[i].color
|
||||
).rgba
|
||||
|
||||
reset()
|
||||
|
||||
timeIt "blendExclusion":
|
||||
for i in 0 ..< iterations:
|
||||
keep blendExclusion(a, b)
|
||||
for i in 0 ..< backdrop.data.len:
|
||||
backdrop.data[i] = blendExclusion(backdrop.data[i], source.data[i])
|
||||
|
||||
reset()
|
||||
|
||||
timeIt "blendExclusionFloats":
|
||||
for i in 0 ..< iterations:
|
||||
keep blendExclusionFloats(a.color, b.color).rgba
|
||||
for i in 0 ..< backdrop.data.len:
|
||||
backdrop.data[i] = blendExclusionFloats(
|
||||
backdrop.data[i].color, source.data[i].color
|
||||
).rgba
|
||||
|
||||
reset()
|
||||
|
||||
timeIt "blendHue":
|
||||
for i in 0 ..< iterations:
|
||||
keep blendHue(a, b)
|
||||
for i in 0 ..< backdrop.data.len:
|
||||
backdrop.data[i] = blendHue(backdrop.data[i], source.data[i])
|
||||
|
||||
reset()
|
||||
|
||||
timeIt "blendHueFloats":
|
||||
for i in 0 ..< iterations:
|
||||
keep blendHueFloats(a.color, b.color).rgba
|
||||
for i in 0 ..< backdrop.data.len:
|
||||
backdrop.data[i] = blendHueFloats(
|
||||
backdrop.data[i].color, source.data[i].color
|
||||
).rgba
|
||||
|
||||
reset()
|
||||
|
||||
timeIt "blendSaturation":
|
||||
for i in 0 ..< iterations:
|
||||
keep blendSaturation(a, b)
|
||||
for i in 0 ..< backdrop.data.len:
|
||||
backdrop.data[i] = blendSaturation(backdrop.data[i], source.data[i])
|
||||
|
||||
reset()
|
||||
|
||||
timeIt "blendSaturationFloats":
|
||||
for i in 0 ..< iterations:
|
||||
keep blendSaturationFloats(a.color, b.color).rgba
|
||||
for i in 0 ..< backdrop.data.len:
|
||||
backdrop.data[i] = blendSaturationFloats(
|
||||
backdrop.data[i].color, source.data[i].color
|
||||
).rgba
|
||||
|
||||
reset()
|
||||
|
||||
timeIt "blendColor":
|
||||
for i in 0 ..< iterations:
|
||||
keep blendColor(a, b)
|
||||
for i in 0 ..< backdrop.data.len:
|
||||
backdrop.data[i] = blendColor(backdrop.data[i], source.data[i])
|
||||
|
||||
reset()
|
||||
|
||||
timeIt "blendColorFloats":
|
||||
for i in 0 ..< iterations:
|
||||
keep blendColorFloats(a.color, b.color).rgba
|
||||
for i in 0 ..< backdrop.data.len:
|
||||
backdrop.data[i] = blendColorFloats(
|
||||
backdrop.data[i].color, source.data[i].color
|
||||
).rgba
|
||||
|
||||
reset()
|
||||
|
||||
timeIt "blendLuminosity":
|
||||
for i in 0 ..< iterations:
|
||||
keep blendLuminosity(a, b)
|
||||
for i in 0 ..< backdrop.data.len:
|
||||
backdrop.data[i] = blendLuminosity(backdrop.data[i], source.data[i])
|
||||
|
||||
reset()
|
||||
|
||||
timeIt "blendLuminosityFloats":
|
||||
for i in 0 ..< iterations:
|
||||
keep blendLuminosityFloats(a.color, b.color).rgba
|
||||
for i in 0 ..< backdrop.data.len:
|
||||
backdrop.data[i] = blendLuminosityFloats(
|
||||
backdrop.data[i].color, source.data[i].color
|
||||
).rgba
|
||||
|
||||
reset()
|
||||
|
||||
timeIt "blendMask":
|
||||
for i in 0 ..< iterations:
|
||||
keep blendMask(a, b)
|
||||
for i in 0 ..< backdrop.data.len:
|
||||
backdrop.data[i] = blendMask(backdrop.data[i], source.data[i])
|
||||
|
||||
reset()
|
||||
|
||||
timeIt "blendMaskFloats":
|
||||
for i in 0 ..< iterations:
|
||||
keep blendMaskFloats(a.color, b.color).rgba
|
||||
for i in 0 ..< backdrop.data.len:
|
||||
backdrop.data[i] = blendMaskFloats(
|
||||
backdrop.data[i].color, source.data[i].color
|
||||
).rgba
|
||||
|
||||
reset()
|
||||
|
||||
timeIt "blendSubtractMask":
|
||||
for i in 0 ..< iterations:
|
||||
keep blendSubtractMask(a, b)
|
||||
for i in 0 ..< backdrop.data.len:
|
||||
backdrop.data[i] = blendSubtractMask(backdrop.data[i], source.data[i])
|
||||
|
||||
reset()
|
||||
|
||||
timeIt "blendSubtractMaskFloats":
|
||||
for i in 0 ..< iterations:
|
||||
keep blendSubtractMaskFloats(a.color, b.color).rgba
|
||||
for i in 0 ..< backdrop.data.len:
|
||||
backdrop.data[i] = blendSubtractMaskFloats(
|
||||
backdrop.data[i].color, source.data[i].color
|
||||
).rgba
|
||||
|
||||
reset()
|
||||
|
||||
timeIt "blendIntersectMask":
|
||||
for i in 0 ..< iterations:
|
||||
keep blendIntersectMask(a, b)
|
||||
for i in 0 ..< backdrop.data.len:
|
||||
backdrop.data[i] = blendIntersectMask(backdrop.data[i], source.data[i])
|
||||
|
||||
reset()
|
||||
|
||||
timeIt "blendIntersectMaskFloats":
|
||||
for i in 0 ..< iterations:
|
||||
keep blendIntersectMaskFloats(a.color, b.color).rgba
|
||||
for i in 0 ..< backdrop.data.len:
|
||||
backdrop.data[i] = blendIntersectMaskFloats(
|
||||
backdrop.data[i].color, source.data[i].color
|
||||
).rgba
|
||||
|
||||
reset()
|
||||
|
||||
timeIt "blendExcludeMask":
|
||||
for i in 0 ..< iterations:
|
||||
keep blendExcludeMask(a, b)
|
||||
for i in 0 ..< backdrop.data.len:
|
||||
backdrop.data[i] = blendExcludeMask(backdrop.data[i], source.data[i])
|
||||
|
||||
reset()
|
||||
|
||||
timeIt "blendExcludeMaskFloats":
|
||||
for i in 0 ..< iterations:
|
||||
keep blendExcludeMaskFloats(a.color, b.color).rgba
|
||||
for i in 0 ..< backdrop.data.len:
|
||||
backdrop.data[i] = blendExcludeMaskFloats(
|
||||
backdrop.data[i].color, source.data[i].color
|
||||
).rgba
|
||||
|
||||
reset()
|
||||
|
|
Loading…
Reference in a new issue