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

image/draw: increase performances by applying special case if mask is *image.Alpha #46395

Closed
owulveryck opened this issue May 26, 2021 · 11 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Performance

Comments

@owulveryck
Copy link
Contributor

What version of Go are you using (go version)?

$ go version
go version devel go1.17-e4615ad74d Wed May 26 13:25:43 2021 +0000 darwin/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE="off"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/olivierwulveryck/Library/Caches/go-build"
GOENV="/Users/olivierwulveryck/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/olivierwulveryck/GOPROJECTS/pkg/mod"
GONOPROXY="github.com/dktunited"
GONOSUMDB="github.com/dktunited"
GOOS="darwin"
GOPATH="/Users/olivierwulveryck/GOPROJECTS"
GOPRIVATE="github.com/dktunited"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/olivierwulveryck/dev/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/olivierwulveryck/dev/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="devel go1.17-e4615ad74d Wed May 26 13:25:43 2021 +0000"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/j3/t2_lsqzd5mgbv7tqvxg9ty5r0000gn/T/go-build4289980978=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I am building a tool that is manipulating a lot of images. The process is a bit slow.
I made some performance analysis, and it appears that the drawRGBA method is really time-consuming.
Specially the call to mask.At(mx,my).RGBA() is causing performance penalty.

I think that most of the use cases of DrawMask function are using an *image.Alpha structure as a mask. Therefore doing a special treatment if the mask is *image.Alpha could be valuable for most of the usage.

I made a simple test and bench for the drawRGBA method (it should be done for other methods as well).

func Benchmark_drawRGBA(b *testing.B) {
	r := image.Rect(0, 0, 500, 500)
	dst := image.NewRGBA(r)
	mask := image.NewAlpha(r)
	src := image.NewRGBA(r)
	for i := 0; i < b.N; i++ {
		drawRGBA(dst, r, src, image.Point{}, mask, image.Point{}, Over)
	}
}

Then I made a patch as an experiment:

diff --git a/src/image/draw/draw.go b/src/image/draw/draw.go
index 8f96aa2d18..205e8cfb43 100644
--- a/src/image/draw/draw.go
+++ b/src/image/draw/draw.go
@@ -530,7 +530,13 @@ func drawRGBA(dst *image.RGBA, r image.Rectangle, src image.Image, sp image.Poin
                for i, sx, mx := i0, sx0, mx0; sx != sx1; i, sx, mx = i+di, sx+dx, mx+dx {
                        ma := uint32(m)
                        if mask != nil {
-                               _, _, _, ma = mask.At(mx, my).RGBA()
+                               if mask, ok := mask.(*image.Alpha); ok {
+                                       off := mask.PixOffset(mx, my)
+                                       ma = uint32(mask.Pix[off])
+                                       ma |= ma << 8
+                               } else {
+                                       _, _, _, ma = mask.At(mx, my).RGBA()
+                               }
                        }
                        sr, sg, sb, sa := src.At(sx, sy).RGBA()
                        d := dst.Pix[i : i+4 : i+4] // Small cap improves performance, see https://golang.org/issue/27857

The performance enhancement is not negligible:

benchmark                 old ns/op     new ns/op     delta
Benchmark_drawRGBA-12     13178981      8599585       -34.75%

benchmark                 old allocs     new allocs     delta
Benchmark_drawRGBA-12     500000         250000         -50.00%

benchmark                 old bytes     new bytes     delta
Benchmark_drawRGBA-12     2025807       1016234       -49.84%

This is a test for opening the discussion, and I guess that other controls should be added as it makes some tests of the draw package fail. Specifically, the test.mask causes panic, and I cannot figure out what test.mask is nor where it is defined.

What did you expect to see?

N/A

What did you see instead?

N/A

@seankhliao seankhliao added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Performance labels May 26, 2021
@seankhliao
Copy link
Member

cc @nigeltao @robpike

@nigeltao
Copy link
Contributor

I'm open in principle to the change, with two comments.

  1. Please be aware of the https://github.com/golang/go/wiki/Go-Release-Cycle
  2. The right fix probably involves touching this switch statement (below) in func DrawMask, and probably involves writing a new func drawMaskOver function instead of tweaking the existing func drawRGBA function.

switch src0 := src.(type) {

@owulveryck
Copy link
Contributor Author

Thanks for your reply.

I thought about adding a private function to replace all the calls to img.At(x,y).RGBA(). This would be less invasive and would benefit all functions of the package.

func rgbaAt(x, y int, img image.Image) (r, g, b, a uint32) {
	switch img0 := img.(type) {
	case *image.RGBA:
		off := img0.PixOffset(x, y)
		r = uint32(img0.Pix[off])
		g = uint32(img0.Pix[off+1])
		b = uint32(img0.Pix[off+2])
		a = uint32(img0.Pix[off+3])
		r |= r << 8
		g |= g << 8
		b |= b << 8
		a |= a << 8
		return
	case *image.Gray:
		off := img0.PixOffset(x, y)
		y := uint32(img0.Pix[off])
		y |= y << 8
		return y, y, y, uint32(0xffff)
	case *image.Alpha:
		off := img0.PixOffset(x, y)
		a := uint32(img0.Pix[off])
		a |= a << 8
		return a, a, a, a
	default:
		return img0.At(x, y).RGBA()

	}
}

I tested it, and the results look very promising. Besides the computation time, it is allocating less memory.
I will submit a patch if it is ok for you.

/tmp/initial.bench/tmp/hack.bench
time/opdelta
FillOver-12995µs ± 0%973µs ± 0%~(p=1.000 n=1+1)
FillSrc-1227.1µs ± 0%25.5µs ± 0%~(p=1.000 n=1+1)
CopyOver-12715µs ± 0%727µs ± 0%~(p=1.000 n=1+1)
CopySrc-1221.8µs ± 0%21.6µs ± 0%~(p=1.000 n=1+1)
NRGBAOver-12863µs ± 0%864µs ± 0%~(p=1.000 n=1+1)
NRGBASrc-12471µs ± 0%472µs ± 0%~(p=1.000 n=1+1)
YCbCr-12433µs ± 0%435µs ± 0%~(p=1.000 n=1+1)
Gray-12151µs ± 0%150µs ± 0%~(p=1.000 n=1+1)
CMYK-12471µs ± 0%509µs ± 0%~(p=1.000 n=1+1)
GlyphOver-12236µs ± 0%240µs ± 0%~(p=1.000 n=1+1)
RGBA-122.96ms ± 0%2.99ms ± 0%~(p=1.000 n=1+1)
PalettedFill-126.47µs ± 0%6.77µs ± 0%~(p=1.000 n=1+1)
PalettedRGBA-121.63ms ± 0%1.63ms ± 0%~(p=1.000 n=1+1)
GenericOver-128.05ms ± 0%8.29ms ± 0%~(p=1.000 n=1+1)
GenericMaskOver-124.21ms ± 0%3.29ms ± 0%~(p=1.000 n=1+1)
GenericSrc-123.34ms ± 0%4.20ms ± 0%~(p=1.000 n=1+1)
GenericMaskSrc-126.22ms ± 0%6.21ms ± 0%~(p=1.000 n=1+1)
_drawRGBA-126.24ms ± 0%3.81ms ± 0%~(p=1.000 n=1+1)
_drawRGBAGray-125.83ms ± 0%3.46ms ± 0%~(p=1.000 n=1+1)
 
alloc/opdelta
FillOver-120.00B 0.00B ~(all equal)
FillSrc-120.00B 0.00B ~(all equal)
CopyOver-120.00B 0.00B ~(all equal)
CopySrc-120.00B 0.00B ~(all equal)
NRGBAOver-120.00B 0.00B ~(all equal)
NRGBASrc-120.00B 0.00B ~(all equal)
YCbCr-120.00B 0.00B ~(all equal)
Gray-120.00B 0.00B ~(all equal)
CMYK-120.00B 0.00B ~(all equal)
GlyphOver-120.00B 0.00B ~(all equal)
RGBA-12960kB ± 0%960kB ± 0%~(p=1.000 n=1+1)
PalettedFill-120.00B 0.00B ~(all equal)
PalettedRGBA-1240.0B ± 0%40.0B ± 0%~(all equal)
GenericOver-122.88MB ± 0%2.88MB ± 0%~(p=1.000 n=1+1)
GenericMaskOver-121.04MB ± 0%0.72MB ± 0%~(p=1.000 n=1+1)
GenericSrc-12960kB ± 0%960kB ± 0%~(all equal)
GenericMaskSrc-122.16MB ± 0%1.20MB ± 0%~(p=1.000 n=1+1)
_drawRGBA-12256kB ± 0%4kB ± 0%~(p=1.000 n=1+1)
_drawRGBAGray-12254kB ± 0%2kB ± 0%~(p=1.000 n=1+1)
 
allocs/opdelta
FillOver-120.00 0.00 ~(all equal)
FillSrc-120.00 0.00 ~(all equal)
CopyOver-120.00 0.00 ~(all equal)
CopySrc-120.00 0.00 ~(all equal)
NRGBAOver-120.00 0.00 ~(all equal)
NRGBASrc-120.00 0.00 ~(all equal)
YCbCr-120.00 0.00 ~(all equal)
Gray-120.00 0.00 ~(all equal)
CMYK-120.00 0.00 ~(all equal)
GlyphOver-120.00 0.00 ~(all equal)
RGBA-12120k ± 0%120k ± 0%~(all equal)
PalettedFill-120.00 0.00 ~(all equal)
PalettedRGBA-122.00 ± 0%2.00 ± 0%~(all equal)
GenericOver-12360k ± 0%360k ± 0%~(all equal)
GenericMaskOver-12210k ± 0%90k ± 0%~(p=1.000 n=1+1)
GenericSrc-12120k ± 0%120k ± 0%~(all equal)
GenericMaskSrc-12270k ± 0%150k ± 0%~(p=1.000 n=1+1)
_drawRGBA-12250k ± 0%0k ~(p=1.000 n=1+1)
_drawRGBAGray-12250k ± 0%0k ~(p=1.000 n=1+1)
 

@nigeltao
Copy link
Contributor

I thought about adding a private function to replace all the calls to img.At(x,y).RGBA().

We don't want to end up with a function call and type switch per pixel. Better to hoist it out of the loop, hence writing a new top-level function.

See also https://go-review.googlesource.com/c/go/+/311129 "image: add RGBA64Image interface".

@gopherbot
Copy link

Change https://golang.org/cl/323749 mentions this issue: image/draw: improve performances if mask is *image.Alpha

@nigeltao
Copy link
Contributor

nigeltao commented Sep 3, 2021

I'd be interested in new "compare to the status quo" benchmark numbers now that "image/draw: add RGBA64Image fast path" https://go-review.googlesource.com/c/go/+/340049 has been submitted.

BTW the "delta" column in the tables from your earlier comment has no numbers.

@owulveryck
Copy link
Contributor Author

I made a bench comparing the master branch (commit ab7c904) (that holds the change you mention including the slowestRGBA struct), and the master branch with the change I made.
Here is the result:

❯ benchstat gotip gotip.hack
name               old time/op    new time/op    delta
FillOver-2           2.56ms ± 0%    2.56ms ± 0%   ~     (p=1.000 n=1+1)
FillSrc-2             186µs ± 0%     189µs ± 0%   ~     (p=1.000 n=1+1)
CopyOver-2           2.02ms ± 0%    2.06ms ± 0%   ~     (p=1.000 n=1+1)
CopySrc-2             112µs ± 0%     115µs ± 0%   ~     (p=1.000 n=1+1)
NRGBAOver-2          2.24ms ± 0%    2.28ms ± 0%   ~     (p=1.000 n=1+1)
NRGBASrc-2           1.19ms ± 0%    1.22ms ± 0%   ~     (p=1.000 n=1+1)
YCbCr-2              1.55ms ± 0%    1.54ms ± 0%   ~     (p=1.000 n=1+1)
Gray-2                360µs ± 0%     360µs ± 0%   ~     (p=1.000 n=1+1)
CMYK-2               1.29ms ± 0%    1.31ms ± 0%   ~     (p=1.000 n=1+1)
GlyphOver-2          1.16ms ± 0%    1.15ms ± 0%   ~     (p=1.000 n=1+1)
RGBA-2               7.69ms ± 0%    7.66ms ± 0%   ~     (p=1.000 n=1+1)
PalettedFill-2       68.6µs ± 0%    68.7µs ± 0%   ~     (p=1.000 n=1+1)
PalettedRGBA-2       4.62ms ± 0%    4.70ms ± 0%   ~     (p=1.000 n=1+1)
GenericOver-2        5.02ms ± 0%    5.20ms ± 0%   ~     (p=1.000 n=1+1)
GenericMaskOver-2    3.01ms ± 0%    3.02ms ± 0%   ~     (p=1.000 n=1+1)
GenericSrc-2         3.18ms ± 0%    3.18ms ± 0%   ~     (p=1.000 n=1+1)
GenericMaskSrc-2     3.62ms ± 0%    3.54ms ± 0%   ~     (p=1.000 n=1+1)
_drawRGBA-2          25.4ms ± 0%     7.7ms ± 0%   ~     (p=1.000 n=1+1)
_drawRGBAGray-2      20.4ms ± 0%     2.9ms ± 0%   ~     (p=1.000 n=1+1)

name               old alloc/op   new alloc/op   delta
FillOver-2            0.00B          0.00B        ~     (all equal)
FillSrc-2             0.00B          0.00B        ~     (all equal)
CopyOver-2            0.00B          0.00B        ~     (all equal)
CopySrc-2             0.00B          0.00B        ~     (all equal)
NRGBAOver-2           0.00B          0.00B        ~     (all equal)
NRGBASrc-2            0.00B          0.00B        ~     (all equal)
YCbCr-2               0.00B          0.00B        ~     (all equal)
Gray-2                0.00B          0.00B        ~     (all equal)
CMYK-2                0.00B          0.00B        ~     (all equal)
GlyphOver-2           0.00B          0.00B        ~     (all equal)
RGBA-2                960kB ± 0%     960kB ± 0%   ~     (all equal)
PalettedFill-2        0.00B          0.00B        ~     (all equal)
PalettedRGBA-2        40.0B ± 0%     40.0B ± 0%   ~     (all equal)
GenericOver-2         0.00B          0.00B        ~     (all equal)
GenericMaskOver-2     0.00B          0.00B        ~     (all equal)
GenericSrc-2          0.00B          0.00B        ~     (all equal)
GenericMaskSrc-2      0.00B          0.00B        ~     (all equal)
_drawRGBA-2          2.03MB ± 0%    0.01MB ± 0%   ~     (p=1.000 n=1+1)
_drawRGBAGray-2       515kB ± 0%       2kB ± 0%   ~     (p=1.000 n=1+1)

name               old allocs/op  new allocs/op  delta
FillOver-2             0.00           0.00        ~     (all equal)
FillSrc-2              0.00           0.00        ~     (all equal)
CopyOver-2             0.00           0.00        ~     (all equal)
CopySrc-2              0.00           0.00        ~     (all equal)
NRGBAOver-2            0.00           0.00        ~     (all equal)
NRGBASrc-2             0.00           0.00        ~     (all equal)
YCbCr-2                0.00           0.00        ~     (all equal)
Gray-2                 0.00           0.00        ~     (all equal)
CMYK-2                 0.00           0.00        ~     (all equal)
GlyphOver-2            0.00           0.00        ~     (all equal)
RGBA-2                 120k ± 0%      120k ± 0%   ~     (all equal)
PalettedFill-2         0.00           0.00        ~     (all equal)
PalettedRGBA-2         2.00 ± 0%      2.00 ± 0%   ~     (all equal)
GenericOver-2          0.00           0.00        ~     (all equal)
GenericMaskOver-2      0.00           0.00        ~     (all equal)
GenericSrc-2           0.00           0.00        ~     (all equal)
GenericMaskSrc-2       0.00           0.00        ~     (all equal)
_drawRGBA-2            500k ± 0%        0k        ~     (p=1.000 n=1+1)
_drawRGBAGray-2        500k ± 0%        0k        ~     (p=1.000 n=1+1)

The last bench are:

package draw

import (
	"image"
	"testing"
)

func Benchmark_drawRGBA(b *testing.B) {
	r := image.Rect(0, 0, 500, 500)
	src := image.NewRGBA(r)
	dst := image.NewRGBA(r)
	mask := image.NewAlpha(r)
	for i := 0; i < b.N; i++ {
		DrawMask(dst, r, src, image.Point{}, mask, image.Point{}, Over)
	}
}

func Benchmark_drawRGBAGray(b *testing.B) {
	r := image.Rect(0, 0, 500, 500)
	// Colors are defined by Red, Green, Blue, Alpha uint8 values.

	src := image.NewGray(r)
	dst := image.NewRGBA(r)
	mask := image.NewAlpha(r)
	for i := 0; i < b.N; i++ {
		DrawMask(dst, r, src, image.Point{}, mask, image.Point{}, Over)
	}
}

I am not sure that is what you want.

@gopherbot
Copy link

Change https://golang.org/cl/351852 mentions this issue: image/draw: add RGBA64Image fast path for RGBA dst

@nigeltao
Copy link
Contributor

Thanks for the new numbers. I overlooked a code path in https://golang.org/cl/340049 which should be addressed by https://golang.org/cl/351852

Once 351852 lands, I'd be curious if you could re-run your benchmarks. I'll repeat that the "delta" column in your tables have no numbers, so it's hard to tell which rows I should focus on.

@nigeltao
Copy link
Contributor

https://golang.org/cl/351852 has landed

gopherbot pushed a commit that referenced this issue Sep 27, 2021
This should have been part of https://golang.org/cl/340049 but I
overlooked it. That commit added fast path code when the destination
image was *not* an *image.RGBA. This commit edits func drawRGBA.

name               old time/op  new time/op  delta
RGBA1-4            5.11ms ± 1%  1.12ms ± 1%  -78.01%  (p=0.008 n=5+5)
RGBA2-4            8.69ms ± 1%  2.98ms ± 1%  -65.77%  (p=0.008 n=5+5)

Updates #44808.
Updates #46395.

Change-Id: I899d46d985634fc81ea47ff4f0d436630e8a961c
Reviewed-on: https://go-review.googlesource.com/c/go/+/351852
Trust: Nigel Tao <nigeltao@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
@owulveryck
Copy link
Contributor Author

Here are the results of my tests:

❯ cat ~/go.516d75ccf1.bench
goos: darwin
goarch: amd64
pkg: image/draw
cpu: Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
BenchmarkFillOver-12           	    1240	    919849 ns/op	       0 B/op	       0 allocs/op
BenchmarkFillSrc-12            	   50834	     24552 ns/op	       0 B/op	       0 allocs/op
BenchmarkCopyOver-12           	    1705	    699634 ns/op	       0 B/op	       0 allocs/op
BenchmarkCopySrc-12            	   55306	     20768 ns/op	       0 B/op	       0 allocs/op
BenchmarkNRGBAOver-12          	    1422	    841424 ns/op	       0 B/op	       0 allocs/op
BenchmarkNRGBASrc-12           	    2649	    464700 ns/op	       0 B/op	       0 allocs/op
BenchmarkYCbCr-12              	    2835	    436423 ns/op	       0 B/op	       0 allocs/op
BenchmarkGray-12               	    8022	    152508 ns/op	       0 B/op	       0 allocs/op
BenchmarkCMYK-12               	    2582	    461211 ns/op	       0 B/op	       0 allocs/op
BenchmarkGlyphOver-12          	    5244	    228985 ns/op	       0 B/op	       0 allocs/op
BenchmarkRGBA1-12              	    1944	    611994 ns/op	       0 B/op	       0 allocs/op
BenchmarkRGBA2-12              	     746	   1626558 ns/op	       0 B/op	       0 allocs/op
BenchmarkPalettedFill-12       	  185510	      6629 ns/op	       0 B/op	       0 allocs/op
BenchmarkPalettedRGBA-12       	     771	   1607542 ns/op	      40 B/op	       2 allocs/op
BenchmarkGenericOver-12        	     745	   1711477 ns/op	       0 B/op	       0 allocs/op
BenchmarkGenericMaskOver-12    	    1329	   1115717 ns/op	       0 B/op	       0 allocs/op
BenchmarkGenericSrc-12         	    1329	    899930 ns/op	       0 B/op	       0 allocs/op
BenchmarkGenericMaskSrc-12     	     982	   1181788 ns/op	       0 B/op	       0 allocs/op
Benchmark_drawRGBA-12          	     355	   3524321 ns/op	    6392 B/op	       0 allocs/op
Benchmark_drawRGBAGray-12      	     432	   2776462 ns/op	    3508 B/op	       0 allocs/op
PASS
ok  	image/draw	28.130s
❯ cat ~/go.25a0774.bench
goos: darwin
goarch: amd64
pkg: image/draw
cpu: Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
BenchmarkFillOver-12           	    1226	    937482 ns/op	       0 B/op	       0 allocs/op
BenchmarkFillSrc-12            	   50300	     24057 ns/op	       0 B/op	       0 allocs/op
BenchmarkCopyOver-12           	    1728	    688587 ns/op	       0 B/op	       0 allocs/op
BenchmarkCopySrc-12            	   56661	     21351 ns/op	       0 B/op	       0 allocs/op
BenchmarkNRGBAOver-12          	    1413	    844938 ns/op	       0 B/op	       0 allocs/op
BenchmarkNRGBASrc-12           	    2599	    459764 ns/op	       0 B/op	       0 allocs/op
BenchmarkYCbCr-12              	    2786	    425523 ns/op	       0 B/op	       0 allocs/op
BenchmarkGray-12               	    8143	    147877 ns/op	       0 B/op	       0 allocs/op
BenchmarkCMYK-12               	    2365	    469891 ns/op	       0 B/op	       0 allocs/op
BenchmarkGlyphOver-12          	    4761	    233635 ns/op	       0 B/op	       0 allocs/op
BenchmarkRGBA1-12              	    1956	    604964 ns/op	       0 B/op	       0 allocs/op
BenchmarkRGBA2-12              	    1064	   1131638 ns/op	       0 B/op	       0 allocs/op
BenchmarkPalettedFill-12       	  182772	      6491 ns/op	       0 B/op	       0 allocs/op
BenchmarkPalettedRGBA-12       	     786	   1536837 ns/op	      40 B/op	       2 allocs/op
BenchmarkGenericOver-12        	     775	   1532559 ns/op	       0 B/op	       0 allocs/op
BenchmarkGenericMaskOver-12    	    1360	    884728 ns/op	       0 B/op	       0 allocs/op
BenchmarkGenericSrc-12         	    1386	    868615 ns/op	       0 B/op	       0 allocs/op
BenchmarkGenericMaskSrc-12     	    1164	   1060872 ns/op	       0 B/op	       0 allocs/op
Benchmark_drawRGBA-12          	     500	   2335115 ns/op	    4538 B/op	       0 allocs/op
Benchmark_drawRGBAGray-12      	    1375	    882834 ns/op	    1102 B/op	       0 allocs/op
PASS
ok  	image/draw	26.094s
❯ benchstat -delta-test none ~/go.516d75ccf1.bench ~/go.25a0774.bench
name                old time/op    new time/op    delta
FillOver-12            920µs ± 0%     937µs ± 0%   +1.92%
FillSrc-12            24.6µs ± 0%    24.1µs ± 0%   -2.02%
CopyOver-12            700µs ± 0%     689µs ± 0%   -1.58%
CopySrc-12            20.8µs ± 0%    21.4µs ± 0%   +2.81%
NRGBAOver-12           841µs ± 0%     845µs ± 0%   +0.42%
NRGBASrc-12            465µs ± 0%     460µs ± 0%   -1.06%
YCbCr-12               436µs ± 0%     426µs ± 0%   -2.50%
Gray-12                153µs ± 0%     148µs ± 0%   -3.04%
CMYK-12                461µs ± 0%     470µs ± 0%   +1.88%
GlyphOver-12           229µs ± 0%     234µs ± 0%   +2.03%
RGBA1-12               612µs ± 0%     605µs ± 0%   -1.15%
RGBA2-12              1.63ms ± 0%    1.13ms ± 0%  -30.43%
PalettedFill-12       6.63µs ± 0%    6.49µs ± 0%   -2.08%
PalettedRGBA-12       1.61ms ± 0%    1.54ms ± 0%   -4.40%
GenericOver-12        1.71ms ± 0%    1.53ms ± 0%  -10.45%
GenericMaskOver-12    1.12ms ± 0%    0.88ms ± 0%  -20.70%
GenericSrc-12          900µs ± 0%     869µs ± 0%   -3.48%
GenericMaskSrc-12     1.18ms ± 0%    1.06ms ± 0%  -10.23%
_drawRGBA-12          3.52ms ± 0%    2.34ms ± 0%  -33.74%
_drawRGBAGray-12      2.78ms ± 0%    0.88ms ± 0%  -68.20%

name                old alloc/op   new alloc/op   delta
FillOver-12            0.00B          0.00B         0.00%
FillSrc-12             0.00B          0.00B         0.00%
CopyOver-12            0.00B          0.00B         0.00%
CopySrc-12             0.00B          0.00B         0.00%
NRGBAOver-12           0.00B          0.00B         0.00%
NRGBASrc-12            0.00B          0.00B         0.00%
YCbCr-12               0.00B          0.00B         0.00%
Gray-12                0.00B          0.00B         0.00%
CMYK-12                0.00B          0.00B         0.00%
GlyphOver-12           0.00B          0.00B         0.00%
RGBA1-12               0.00B          0.00B         0.00%
RGBA2-12               0.00B          0.00B         0.00%
PalettedFill-12        0.00B          0.00B         0.00%
PalettedRGBA-12        40.0B ± 0%     40.0B ± 0%    0.00%
GenericOver-12         0.00B          0.00B         0.00%
GenericMaskOver-12     0.00B          0.00B         0.00%
GenericSrc-12          0.00B          0.00B         0.00%
GenericMaskSrc-12      0.00B          0.00B         0.00%
_drawRGBA-12          6.39kB ± 0%    4.54kB ± 0%  -29.01%
_drawRGBAGray-12      3.51kB ± 0%    1.10kB ± 0%  -68.59%

name                old allocs/op  new allocs/op  delta
FillOver-12             0.00           0.00         0.00%
FillSrc-12              0.00           0.00         0.00%
CopyOver-12             0.00           0.00         0.00%
CopySrc-12              0.00           0.00         0.00%
NRGBAOver-12            0.00           0.00         0.00%
NRGBASrc-12             0.00           0.00         0.00%
YCbCr-12                0.00           0.00         0.00%
Gray-12                 0.00           0.00         0.00%
CMYK-12                 0.00           0.00         0.00%
GlyphOver-12            0.00           0.00         0.00%
RGBA1-12                0.00           0.00         0.00%
RGBA2-12                0.00           0.00         0.00%
PalettedFill-12         0.00           0.00         0.00%
PalettedRGBA-12         2.00 ± 0%      2.00 ± 0%    0.00%
GenericOver-12          0.00           0.00         0.00%
GenericMaskOver-12      0.00           0.00         0.00%
GenericSrc-12           0.00           0.00         0.00%
GenericMaskSrc-12       0.00           0.00         0.00%
_drawRGBA-12            0.00           0.00         0.00%
_drawRGBAGray-12        0.00           0.00         0.00%

@golang golang locked and limited conversation to collaborators Oct 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Performance
Projects
None yet
Development

No branches or pull requests

4 participants