/
benchGetRows.go
42 lines (38 loc) · 881 Bytes
/
benchGetRows.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright 2021-2023 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license.
//
// This is a benchmark script for the Go language Spreadsheet (Excel / XLSX)
// library excelize: https://github.com/xuri/excelize
package main
import (
"fmt"
"runtime"
"time"
"github.com/xuri/excelize"
)
func benchGetRows(row, col int) {
runtime.GC()
startTime := time.Now()
f, err := excelize.OpenFile(fmt.Sprintf("StreamWriter_r%dxc%d.xlsx", row, col))
if err != nil {
fmt.Println(err)
return
}
c := 0
rows, err := f.GetRows("Sheet1")
if err != nil {
fmt.Println(err)
return
}
for _, r := range rows {
for _, colCell := range r {
_ = colCell
c++
}
}
if c != row*col {
fmt.Println("Test GetRows Error", c, row*col)
return
}
printBenchmarkInfo(fmt.Sprintf("GetRows_r%dxc%d.xlsx", row, col), startTime)
}