-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
同期処理もあり、CLIの出力が固まるレベルでパフォーマンスが悪い。
tools/packages/@d-zero/archaeologist/src/diff-images.ts
Lines 23 to 45 in 72026b8
| listener('create', { a: dataA.binary, b: dataB.binary }); | |
| const imgA = PNG.sync.read(dataA.binary); | |
| const imgB = PNG.sync.read(dataB.binary); | |
| const width = Math.max(imgA.width, imgB.width); | |
| const height = Math.max(imgA.height, imgB.height); | |
| listener('resize', { a: dataA.binary, b: dataB.binary, width, height }); | |
| const resizedA = await resizeImg(dataA.binary, width, height); | |
| const resizedB = await resizeImg(dataB.binary, width, height); | |
| listener('diff', { a: resizedA, b: resizedB }); | |
| const imgA_ = PNG.sync.read(resizedA); | |
| const imgB_ = PNG.sync.read(resizedB); | |
| const diffImage = new PNG({ width, height }); | |
| const matcheBytes = pixelmatch(imgA_.data, imgB_.data, diffImage.data, width, height); | |
| const matches = 1 - matcheBytes / (width * height); | |
| const imageABuffer = PNG.sync.write(imgA_); | |
| const imageBBuffer = PNG.sync.write(imgB_); | |
| const imageDiffBuffer = PNG.sync.write(diffImage); |
非同期にしたり、worker_threadsを使ってサブプロセスに逃がすことを検討する。
Metadata
Metadata
Assignees
Labels
No labels