Skip to content

[Archaeologist] 画像処理のパフォーマンス向上 #14

@YusukeHirao

Description

@YusukeHirao

同期処理もあり、CLIの出力が固まるレベルでパフォーマンスが悪い。

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions