Skip to content

Commit

Permalink
ベンチマークは取ったので古い方式は削除してimaging依存を消す
Browse files Browse the repository at this point in the history
Signed-off-by: drumato <[email protected]>
  • Loading branch information
Drumato committed Apr 11, 2024
1 parent 75913bc commit fe504ce
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 55 deletions.
7 changes: 1 addition & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,4 @@ module github.com/pepabo/oyaki

go 1.19

require (
github.com/disintegration/imaging v1.6.2
github.com/h2non/bimg v1.1.9
)

require golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8 // indirect
require github.com/h2non/bimg v1.1.9
5 changes: 0 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
github.com/disintegration/imaging v1.6.2 h1:w1LecBlG2Lnp8B3jk5zSuNqd7b4DXhcjwek1ei82L+c=
github.com/disintegration/imaging v1.6.2/go.mod h1:44/5580QXChDfwIclfc/PCwrr44amcmDAg8hxG0Ewe4=
github.com/h2non/bimg v1.1.9 h1:WH20Nxko9l/HFm4kZCA3Phbgu2cbHvYzxwxn9YROEGg=
github.com/h2non/bimg v1.1.9/go.mod h1:R3+UiYwkK4rQl6KVFTOFJHitgLbZXBZNFh2cv3AEbp8=
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8 h1:hVwzHzIUGRjiF7EcUjqNxk3NCfkPxbDKRdnNE1Rpg0U=
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
44 changes: 0 additions & 44 deletions webp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ import (
"net/http"
"net/http/httptest"
"os"
"os/exec"
"testing"

"github.com/disintegration/imaging"
)

func TestProxyWebP(t *testing.T) {
Expand Down Expand Up @@ -60,47 +57,6 @@ func TestConvJPG2WebP(t *testing.T) {

}

func BenchmarkConvJPG2WebP_OldCwebpMethod(b *testing.B) {
tmpF, err := os.CreateTemp("/tmp", "")
if err != nil {
b.Fatal("failed to create tmp file")
}
defer tmpF.Close()
defer os.Remove(tmpF.Name())

f, err := os.Open("./testdata/oyaki.jpg")
if err != nil {
b.Fatal("failed to open testdata")
}
defer f.Close()

// to re-use src bytes
src, err := io.ReadAll(f)
if err != nil {
b.Fatal("failed to open testdata")
}

b.ResetTimer()
for i := 0; i < b.N; i++ {
b.StopTimer()
srcBuf := bytes.NewBuffer(src)
b.StartTimer()
img, err := imaging.Decode(srcBuf, imaging.AutoOrientation(true))
if err != nil {
b.Fail()
}

if err := imaging.Encode(tmpF, img, imaging.JPEG); err != nil {
b.Fail()
}

params := []string{"-quiet", "-mt", "-jpeg_like", f.Name(), "-o", "-"}
if _, err = exec.Command("cwebp", params...).Output(); err != nil {
b.Fail()
}
}
}

func BenchmarkConvJPG2WebP_bimg(b *testing.B) {
f, err := os.Open("./testdata/oyaki.jpg")
if err != nil {
Expand Down

0 comments on commit fe504ce

Please sign in to comment.