picture_test.go 440 B

123456789101112131415161718192021
  1. package excelize
  2. import (
  3. "fmt"
  4. _ "image/png"
  5. "io/ioutil"
  6. "path/filepath"
  7. "testing"
  8. )
  9. func BenchmarkAddPictureFromBytes(b *testing.B) {
  10. f := NewFile()
  11. imgFile, err := ioutil.ReadFile(filepath.Join("test", "images", "excel.png"))
  12. if err != nil {
  13. b.Error("unable to load image for benchmark")
  14. }
  15. b.ResetTimer()
  16. for i := 1; i <= b.N; i++ {
  17. f.AddPictureFromBytes("Sheet1", fmt.Sprint("A", i), "", "excel", ".png", imgFile)
  18. }
  19. }