From 2874d75555102b8266477cdda2966ff37dde6b12 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 23 Mar 2019 03:09:48 -0500 Subject: Add benchmark for adding images to sheet (#367) * Add benchmark for adding images to sheet This should help track performance regressions in future changes. * Only transform sheet name if necessary --- picture_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 picture_test.go (limited to 'picture_test.go') diff --git a/picture_test.go b/picture_test.go new file mode 100644 index 0000000..97d3cd9 --- /dev/null +++ b/picture_test.go @@ -0,0 +1,20 @@ +package excelize + +import ( + "fmt" + _ "image/png" + "io/ioutil" + "testing" +) + +func BenchmarkAddPictureFromBytes(b *testing.B) { + f := NewFile() + imgFile, err := ioutil.ReadFile("logo.png") + if err != nil { + panic("unable to load image for benchmark") + } + b.ResetTimer() + for i := 1; i <= b.N; i++ { + f.AddPictureFromBytes("Sheet1", fmt.Sprint("A", i), "", "logo", ".png", imgFile) + } +} -- cgit v1.2.1