fix bench_jpeg, change benchy and xray format.

This commit is contained in:
treeform 2022-07-09 23:26:52 -07:00
parent 84e86a8c30
commit 4b3e205445
3 changed files with 13 additions and 24 deletions

View file

@ -1,19 +1,17 @@
import benchy, jpegsuite, pixie/fileformats/jpeg, stb_image/read as stbi,
strformat, os
import benchy, pixie/fileformats/jpeg, jpegsuite, os, stb_image/read as stbi
for file in jpegSuiteFiles:
let data = readFile(file)
var name = file.splitPath.tail
name.setLen(min(name.len, 22))
timeIt &"pixie {name} decode":
timeIt "pixie " & file.splitPath.tail & " decode", 10:
discard decodeJpeg(data)
block:
for file in jpegSuiteFiles:
let data = readFile(file)
var name = file.splitPath.tail
name.setLen(min(name.len, 22))
timeIt &"stb {name} decode":
timeIt "stb " & file.splitPath.tail & " decode", 10:
var width, height, channels: int
discard loadFromMemory(
cast[seq[byte]](data),

View file

@ -279,7 +279,7 @@ block:
image.draw(strokeImage)
image.xray("tests/images/fillOptimization.png")
# doAssert image[10, 10] == rgbx(255, 127, 63, 255)
doAssert image[10, 10] == rgbx(255, 127, 63, 255)
block:
let a = newImage(100, 100)

View file

@ -1,26 +1,17 @@
import pixie, strformat, os, strutils
proc makeDirs*(dirs: string) =
var path = ""
for dir in dirs.split("/"):
path.add dir
if not dirExists(path):
echo "mkdir ", path
createDir(path)
path.add "/"
proc xray*(image: Image, masterPath: string) =
let
imagePath = "tmp/generated/" & masterPath
xRayPath = "tmp/xray/" & masterPath
makeDirs(imagePath.splitPath.head)
makeDirs(xRayPath.splitPath.head)
image.writeFile(imagePath)
generatedPath = "tmp/generated/" & masterPath
xrayPath = "tmp/xray/" & masterPath
createDir(generatedPath.splitPath.head)
createDir(xrayPath.splitPath.head)
image.writeFile(generatedPath)
let
master = readImage(masterPath)
(score, xRay) = diff(image, master)
xRay.writeFile(xRayPath)
echo &"diff {masterPath} -> {score:0.6f}"
xRay.writeFile(xrayPath)
echo &"xray {masterPath} -> {score:0.6f}"
proc xray*(mask: Mask, masterPath: string) =
mask.newImage.xray(masterPath)