Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
liaosimin-heygen opened this issue Jan 15, 2024 · 0 comments

Comments

@liaosimin-heygen
Copy link

`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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant