From 0f9170a03b9fe19c1c22687fba8bcbdfd69a6347 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 16 Apr 2019 01:50:16 -0500 Subject: 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 --- cell_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'cell_test.go') 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]) + } + } +} -- cgit v1.2.1