pixie/tests/benchmark_images.nim

51 lines
926 B
Nim
Raw Normal View History

2021-01-23 20:17:28 +00:00
import chroma, pixie, benchy
2020-12-03 20:21:58 +00:00
2021-01-06 20:18:47 +00:00
let a = newImage(2560, 1440)
2020-12-03 20:21:58 +00:00
timeIt "fill":
2020-12-04 06:11:54 +00:00
a.fill(rgba(255, 255, 255, 255))
2020-12-03 20:21:58 +00:00
doAssert a[0, 0] == rgba(255, 255, 255, 255)
2020-12-09 00:10:20 +00:00
timeIt "fill_rgba":
2021-01-24 22:03:35 +00:00
a.fill(rgba(63, 127, 191, 191))
doAssert a[0, 0] == rgba(63, 127, 191, 191)
2020-12-09 00:10:20 +00:00
2021-01-23 20:17:28 +00:00
timeIt "subImage":
keep a.subImage(0, 0, 256, 256)
2020-12-03 20:21:58 +00:00
timeIt "invert":
2020-12-04 06:11:54 +00:00
a.invert()
keep(a)
2020-12-03 20:32:50 +00:00
timeIt "applyOpacity":
2020-12-04 06:11:54 +00:00
a.applyOpacity(0.5)
keep(a)
2020-12-03 20:32:50 +00:00
timeIt "sharpOpacity":
2020-12-04 06:11:54 +00:00
a.sharpOpacity()
keep(a)
2021-01-24 22:03:35 +00:00
a.fill(rgba(63, 127, 191, 191))
timeIt "toAlphy":
a.toAlphy()
timeIt "fromAlphy":
a.fromAlphy()
timeIt "lerp integers":
for i in 0 ..< 100000:
let c = a[0, 0]
var z: int
for t in 0 .. 100:
z += lerp(c, c, t.float32 / 100).a.int
doAssert z > 0
timeIt "lerp floats":
for i in 0 ..< 100000:
let c = a[0, 0]
var z: int
for t in 0 .. 100:
z += lerp(c.color, c.color, t.float32 / 100).rgba().a.int
doAssert z > 0