2019-03-23 16:09:48 +08:00
|
|
|
package excelize
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
_ "image/png"
|
|
|
|
"io/ioutil"
|
2019-03-23 20:08:06 +08:00
|
|
|
"path/filepath"
|
2019-03-23 16:09:48 +08:00
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func BenchmarkAddPictureFromBytes(b *testing.B) {
|
|
|
|
f := NewFile()
|
2019-03-23 20:08:06 +08:00
|
|
|
imgFile, err := ioutil.ReadFile(filepath.Join("test", "images", "excel.png"))
|
2019-03-23 16:09:48 +08:00
|
|
|
if err != nil {
|
2019-03-23 20:08:06 +08:00
|
|
|
b.Error("unable to load image for benchmark")
|
2019-03-23 16:09:48 +08:00
|
|
|
}
|
|
|
|
b.ResetTimer()
|
|
|
|
for i := 1; i <= b.N; i++ {
|
2019-03-23 20:08:06 +08:00
|
|
|
f.AddPictureFromBytes("Sheet1", fmt.Sprint("A", i), "", "excel", ".png", imgFile)
|
2019-03-23 16:09:48 +08:00
|
|
|
}
|
|
|
|
}
|