2019-10-28 23:34:21 +08:00
|
|
|
package excelize
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func BenchmarkWrite(b *testing.B) {
|
|
|
|
const s = "This is test data"
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
f := NewFile()
|
|
|
|
for row := 1; row <= 10000; row++ {
|
|
|
|
for col := 1; col <= 20; col++ {
|
|
|
|
val, err := CoordinatesToCellName(col, row)
|
|
|
|
if err != nil {
|
2020-01-03 23:57:25 +08:00
|
|
|
b.Error(err)
|
2019-10-28 23:34:21 +08:00
|
|
|
}
|
2019-12-24 01:09:28 +08:00
|
|
|
if err := f.SetCellDefault("Sheet1", val, s); err != nil {
|
2020-01-03 23:57:25 +08:00
|
|
|
b.Error(err)
|
2019-12-24 01:09:28 +08:00
|
|
|
}
|
2019-10-28 23:34:21 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// Save xlsx file by the given path.
|
|
|
|
err := f.SaveAs("./test.xlsx")
|
|
|
|
if err != nil {
|
2020-01-03 23:57:25 +08:00
|
|
|
b.Error(err)
|
2019-10-28 23:34:21 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|