File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -1156,6 +1156,7 @@ func TestFile_CountRows(t *testing.T) {
1156
1156
t .Run (tt .name , func (t * testing.T ) {
1157
1157
f , err := OpenFile (tt .fields .filename )
1158
1158
assert .NoError (t , err )
1159
+ defer f .Close ()
1159
1160
firstSheet := f .GetSheetName (0 )
1160
1161
got , err := f .CountRows (firstSheet )
1161
1162
if ! tt .wantErr (t , err , "CountRows" ) {
@@ -1165,3 +1166,28 @@ func TestFile_CountRows(t *testing.T) {
1165
1166
})
1166
1167
}
1167
1168
}
1169
+
1170
+ func BenchmarkFile_GetRows_Old (b * testing.B ) {
1171
+ for i := 0 ; i < b .N ; i ++ {
1172
+ f , _ := OpenFile (filepath .Join ("test" , "Book1.xlsx" ))
1173
+ defer f .Close ()
1174
+
1175
+ firstSheet := f .GetSheetName (0 )
1176
+ count := 0
1177
+ rows , _ := f .GetRows (firstSheet )
1178
+ for range rows {
1179
+ count ++
1180
+ }
1181
+ }
1182
+ }
1183
+
1184
+ func BenchmarkFile_GetRows_New (b * testing.B ) {
1185
+ for i := 0 ; i < b .N ; i ++ {
1186
+ f , _ := OpenFile (filepath .Join ("test" , "Book1.xlsx" ))
1187
+ defer f .Close ()
1188
+
1189
+ firstSheet := f .GetSheetName (0 )
1190
+ _ , err := f .CountRows (firstSheet )
1191
+ assert .NoError (b , err )
1192
+ }
1193
+ }
You can’t perform that action at this time.
0 commit comments