chai2010 / chai2010/webp

为什么使用github.com/chai2010/webp的decode性能只有golang.org/x/image/webp的一半?是我使用方式不对吗?

Open
#66 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
723
Forks
113
PR merge metrics
No merged PRs in 30d

Description

`import (
"fmt"
"image"
"os"
"time"
"bytes"

//"golang.org/x/image/webp"
"github.com/chai2010/webp"
)

func webpToYuv(imgpath string) *image.Image {
defer timeCost("webpToYuv:", time.Now())

// 打开WebP文件
start := time.Now()
data,err:=os.ReadFile(imgpath)
if err != nil {
fmt.Println("open webp file failed:", err)
return nil
}
fmt.Printf("读取文件 %s 耗时:%s\n", imgpath, time.Since(start))

// 解码WebP文件
start2 := time.Now()
result, err := webp.Decode(bytes.NewReader(data))
if err != nil {
fmt.Println("decode webp file failed:", err)
return nil
}
fmt.Printf("解码文件 %s 耗时:%s\n", imgpath, time.Since(start2))

return &result
}
`
使用golang.org/x/image/webp的结果:
webpToYuv: took 51.727646ms
读取文件 /mnt/realtime/josh_lite3_20230714/rgb/cluster_1/00814.webp 耗时:8.154499ms
解码文件 /mnt/realtime/josh_lite3_20230714/rgb/cluster_1/00814.webp 耗时:44.984073ms

使用github.com/chai2010/webp的结果:
webpToYuv: took 105.325294ms
读取文件 /mnt/realtime/josh_lite3_20230714/rgb/cluster_1/00797.webp 耗时:1.161915ms
解码文件 /mnt/realtime/josh_lite3_20230714/rgb/cluster_1/00797.webp 耗时:99.458595ms

Contributor guide

No contributing guide indexed for this repository

Research direction

No repository files or tests are named. Start by reproducing the benchmark with the same WebP input and comparing the two Decode calls, then inspect the decoder entry points and any performance-related documentation. Done means identifying whether the usage is incorrect or documenting an actionable cause for the speed difference.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.