Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Drumato
Copy link

@Drumato Drumato commented Apr 10, 2024

外部コマンドでcwebpを使って変換するのではなく、bimg(libvips)で変換するように書き換えました。
Cライブラリを使うためにDockerfileのベースイメージをdistrolessからdebianに変え、 CGO_ENABLED=0 を削除しました。

また、imagingを使って変換していた(webpではない)プロキシも置き換えました

ベンチマーク

従来の方法

BenchmarkProxyJpeg-12                      	      36	  32134368 ns/op	 2732786 B/op	     305 allocs/op
BenchmarkProxyPNG-12                       	     741	   1539859 ns/op	 5365531 B/op	     226 allocs/op
BenchmarkConvJPG2WebP_OldCwebpMethod-12    	      13	  85976654 ns/op	 1777722 B/op	     186 allocs/op

置き換え後
quality指定なし

BenchmarkProxyJpeg-12            	      67	  17042145 ns/op	 3866607 B/op	     249 allocs/op
BenchmarkProxyPNG-12             	     762	   1599133 ns/op	 5365836 B/op	     226 allocs/op
BenchmarkConvJPG2WebP_bimg-12    	      26	  44308845 ns/op	 3308000 B/op	      31 allocs/op

quality指定あり

BenchmarkProxyJpeg-12            	      81	  13760491 ns/op	 4392313 B/op	     247 allocs/op
BenchmarkProxyPNG-12             	     758	   1431104 ns/op	 5362828 B/op	     227 allocs/op
BenchmarkConvJPG2WebP_bimg-12    	      21	  58375780 ns/op	 3381610 B/op	      31 allocs/op

@Drumato Drumato requested a review from takutakahashi April 10, 2024 10:57
Copy link

@takutakahashi takutakahashi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Drumato Drumato merged commit 4ba4c30 into master Oct 28, 2024
@Drumato Drumato deleted the use-bimg branch October 28, 2024 06:16
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

Successfully merging this pull request may close these issues.

3 participants