picture_test.go 440 字节
Newer Older
1 2 3 4 5 6
package excelize

import (
	"fmt"
	_ "image/png"
	"io/ioutil"
7
	"path/filepath"
8 9 10 11 12
	"testing"
)

func BenchmarkAddPictureFromBytes(b *testing.B) {
	f := NewFile()
13
	imgFile, err := ioutil.ReadFile(filepath.Join("test", "images", "excel.png"))
14
	if err != nil {
15
		b.Error("unable to load image for benchmark")
16 17 18
	}
	b.ResetTimer()
	for i := 1; i <= b.N; i++ {
19
		f.AddPictureFromBytes("Sheet1", fmt.Sprint("A", i), "", "excel", ".png", imgFile)
20 21
	}
}