1
+ /* global console */
1
2
var test = require ( 'tape' ) ;
2
3
var HTML = require ( '../index' ) ;
3
4
4
5
5
6
test ( 'parse' , function ( t ) {
6
7
var html = '<div class="oh"><p></p></div>' ;
7
- var parsed = HTML . parse ( html ) ;
8
+ var parsed = HTML . parse ( html ) ;
8
9
t . deepEqual ( parsed , [ {
9
10
type : 'tag' ,
10
11
name : 'div' ,
@@ -278,12 +279,13 @@ test('simple speed sanity check', function (t) {
278
279
var waitLoopSize = 10000000 ;
279
280
var groups = i / groupSize ;
280
281
var html = '<html><head><title>Some page</title></head><body class="hey there"><img src="someURL"><h3>Hey, we need content</h3><br></body></html>' ;
281
-
282
+
282
283
var parse = HTML . parse ;
283
284
var times = [ ] ;
284
285
var count ;
285
286
var waitCount ;
286
287
var total = 0 ;
288
+ var start , stepAverage ;
287
289
288
290
console . log ( 'running ' + i + ' iterations...' ) ;
289
291
@@ -296,10 +298,10 @@ test('simple speed sanity check', function (t) {
296
298
parse ( html ) ;
297
299
}
298
300
var diff = Date . now ( ) - start ;
299
- var average = diff / groupSize
300
- console . log ( 'group ' + ( groups - ( i / groupSize ) ) + ': ' + average ) ;
301
- times . push ( average ) ;
302
- total += average ;
301
+ stepAverage = diff / groupSize ;
302
+ console . log ( 'group ' + ( groups - ( i / groupSize ) ) + ': ' + stepAverage ) ;
303
+ times . push ( stepAverage ) ;
304
+ total += stepAverage ;
303
305
waitCount = waitLoopSize ;
304
306
// forcing a bit of a pause between tests
305
307
while ( waitCount -- ) { }
@@ -308,8 +310,8 @@ test('simple speed sanity check', function (t) {
308
310
}
309
311
310
312
// trim off first
311
- // it's always a slower outlier
312
- // with higher variability that
313
+ // it's always a slower outlier
314
+ // with higher variability that
313
315
// makes it harder to find differences
314
316
times . shift ( ) ;
315
317
@@ -320,6 +322,6 @@ test('simple speed sanity check', function (t) {
320
322
console . log ( 'max' , max ) ;
321
323
console . log ( 'min' , min ) ;
322
324
console . log ( 'avg' , average ) ;
323
-
325
+
324
326
t . end ( ) ;
325
327
} ) ;
0 commit comments