summaryrefslogtreecommitdiff
path: root/cell_test.go
diff options
context:
space:
mode:
authorMichael <osiris2918@gmail.com>2019-04-16 01:50:16 -0500
committerxuri <xuri.me@gmail.com>2019-04-16 14:50:16 +0800
commit0f9170a03b9fe19c1c22687fba8bcbdfd69a6347 (patch)
treebc7e73c690d274548530199de14c4d668d45c118 /cell_test.go
parenta88459d5f1e83006ba421f334a1513d1c231eb6b (diff)
Resolve #382, rewrite prepareSheetXML to scale linearly (#383)
* Rewrite prepareSheetXML to scale linearly We don't need to backfill columns into every row for most purposes Provided makeContiguousColumns for setting styles where we do need it for a specific region. Added a benchmark to monitor progress. For 50,000 rows this went from about 11 seconds to 1 second. The improvements are more dramatic as the row/column count increases. * Assigning that row value was redundant
Diffstat (limited to 'cell_test.go')
-rw-r--r--cell_test.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/cell_test.go b/cell_test.go
index 7b1381f..d4a5b02 100644
--- a/cell_test.go
+++ b/cell_test.go
@@ -82,3 +82,15 @@ func ExampleFile_SetCellFloat() {
fmt.Println(val)
// Output: 3.14
}
+
+func BenchmarkSetCellValue(b *testing.B) {
+ values := []string{"First", "Second", "Third", "Fourth", "Fifth", "Sixth"}
+ cols := []string{"A", "B", "C", "D", "E", "F"}
+ f := NewFile()
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ for j := 0; j < len(values); j++ {
+ f.SetCellValue("Sheet1", fmt.Sprint(cols[j], i), values[j])
+ }
+ }
+}