Skip to content

Commit

Permalink
qax-os#1402 Get CountRows from sheet
Browse files Browse the repository at this point in the history
add close file and benchmark
  • Loading branch information
ivolkoff committed Nov 25, 2022
1 parent ea542a0 commit a27fa78
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions rows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1156,6 +1156,7 @@ func TestFile_CountRows(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
f, err := OpenFile(tt.fields.filename)
assert.NoError(t, err)
defer f.Close()
firstSheet := f.GetSheetName(0)
got, err := f.CountRows(firstSheet)
if !tt.wantErr(t, err, "CountRows") {
Expand All @@ -1165,3 +1166,28 @@ func TestFile_CountRows(t *testing.T) {
})
}
}

func BenchmarkFile_GetRows_Old(b *testing.B) {
for i := 0; i < b.N; i++ {
f, _ := OpenFile(filepath.Join("test", "Book1.xlsx"))
defer f.Close()

firstSheet := f.GetSheetName(0)
count := 0
rows, _ := f.GetRows(firstSheet)
for range rows {
count++
}
}
}

func BenchmarkFile_GetRows_New(b *testing.B) {
for i := 0; i < b.N; i++ {
f, _ := OpenFile(filepath.Join("test", "Book1.xlsx"))
defer f.Close()

firstSheet := f.GetSheetName(0)
_, err := f.CountRows(firstSheet)
assert.NoError(b, err)
}
}

0 comments on commit a27fa78

Please sign in to comment.