@@ -41,6 +41,21 @@ for (let { name, buffers} of config) {
41
41
suites . push ( getByIndexSuite , iterateSuite , sliceSuite , parseSuite ) ;
42
42
}
43
43
44
+ for ( let { name, buffers, tests} of require ( './table_config' ) ) {
45
+ const tableIterateSuite = new Benchmark . Suite ( `Table Iterate ${ name } ` , { async : true } ) ;
46
+ const tableCountBySuite = new Benchmark . Suite ( `Table Count By ${ name } ` , { async : true } ) ;
47
+ const vectorCountBySuite = new Benchmark . Suite ( `Vector Count By ${ name } ` , { async : true } ) ;
48
+ const table = Table . from ( buffers ) ;
49
+
50
+ tableIterateSuite . add ( createTableIterateTest ( table ) ) ;
51
+ for ( test of tests ) {
52
+ tableCountBySuite . add ( createTableCountByTest ( table , test . col , test . test , test . value ) )
53
+ vectorCountBySuite . add ( createVectorCountByTest ( table . columns [ test . col ] , test . test , test . value ) )
54
+ }
55
+
56
+ suites . push ( tableIterateSuite , tableCountBySuite , vectorCountBySuite )
57
+ }
58
+
44
59
console . log ( 'Running apache-arrow performance tests...\n' ) ;
45
60
46
61
run ( ) ;
@@ -109,3 +124,66 @@ function createGetByIndexTest(vector) {
109
124
}
110
125
} ;
111
126
}
127
+
128
+ function createVectorCountByTest ( vector , test , value ) {
129
+ let op ;
130
+ if ( test == 'gteq' ) {
131
+ op = function ( ) {
132
+ sum = 0 ;
133
+ for ( cell of vector ) {
134
+ sum += ( cell >= value )
135
+ }
136
+ }
137
+ } else if ( test == 'eq' ) {
138
+ op = function ( ) {
139
+ sum = 0 ;
140
+ for ( cell of vector ) {
141
+ sum += ( cell == value )
142
+ }
143
+ }
144
+ } else {
145
+ throw new Error ( `Unrecognized test "$test"` ) ;
146
+ }
147
+
148
+ return {
149
+ async : true ,
150
+ name : `name: '${ vector . name } ', length: ${ vector . length } , type: ${ vector . type } , test: ${ test } , value: ${ value } ` ,
151
+ fn : op
152
+ } ;
153
+ }
154
+
155
+ function createTableIterateTest ( table ) {
156
+ let row ;
157
+ return {
158
+ async : true ,
159
+ name : `length: ${ table . length } ` ,
160
+ fn ( ) { for ( row of table ) { } }
161
+ } ;
162
+ }
163
+
164
+ function createTableCountByTest ( table , column , test , value ) {
165
+ let op ;
166
+ if ( test == 'gteq' ) {
167
+ op = function ( ) {
168
+ sum = 0 ;
169
+ for ( row of table ) {
170
+ sum += ( row . get ( column ) >= value )
171
+ }
172
+ }
173
+ } else if ( test == 'eq' ) {
174
+ op = function ( ) {
175
+ sum = 0 ;
176
+ for ( row of table ) {
177
+ sum += ( row . get ( column ) == value )
178
+ }
179
+ }
180
+ } else {
181
+ throw new Error ( `Unrecognized test "${ test } "` ) ;
182
+ }
183
+
184
+ return {
185
+ async : true ,
186
+ name : `name: '${ table . columns [ column ] . name } ', length: ${ table . length } , type: ${ table . columns [ column ] . type } , test: ${ test } , value: ${ value } ` ,
187
+ fn : op
188
+ } ;
189
+ }
0 commit comments