@@ -26,19 +26,17 @@ function main({ len, n, source }) {
26
26
const uint8array = new Uint8Array ( len ) ;
27
27
const obj = { length : null } ; // Results in a new, empty Buffer
28
28
29
- var i ;
30
-
31
29
switch ( source ) {
32
30
case 'array' :
33
31
bench . start ( ) ;
34
- for ( i = 0 ; i < n * 1024 ; i ++ ) {
32
+ for ( let i = 0 ; i < n * 1024 ; i ++ ) {
35
33
Buffer . from ( array ) ;
36
34
}
37
35
bench . end ( n ) ;
38
36
break ;
39
37
case 'arraybuffer' :
40
38
bench . start ( ) ;
41
- for ( i = 0 ; i < n * 1024 ; i ++ ) {
39
+ for ( let i = 0 ; i < n * 1024 ; i ++ ) {
42
40
Buffer . from ( arrayBuf ) ;
43
41
}
44
42
bench . end ( n ) ;
@@ -47,54 +45,54 @@ function main({ len, n, source }) {
47
45
const offset = ~ ~ ( len / 4 ) ;
48
46
const length = ~ ~ ( len / 2 ) ;
49
47
bench . start ( ) ;
50
- for ( i = 0 ; i < n * 1024 ; i ++ ) {
48
+ for ( let i = 0 ; i < n * 1024 ; i ++ ) {
51
49
Buffer . from ( arrayBuf , offset , length ) ;
52
50
}
53
51
bench . end ( n ) ;
54
52
break ;
55
53
case 'buffer' :
56
54
bench . start ( ) ;
57
- for ( i = 0 ; i < n * 1024 ; i ++ ) {
55
+ for ( let i = 0 ; i < n * 1024 ; i ++ ) {
58
56
Buffer . from ( buffer ) ;
59
57
}
60
58
bench . end ( n ) ;
61
59
break ;
62
60
case 'uint8array' :
63
61
bench . start ( ) ;
64
- for ( i = 0 ; i < n * 1024 ; i ++ ) {
62
+ for ( let i = 0 ; i < n * 1024 ; i ++ ) {
65
63
Buffer . from ( uint8array ) ;
66
64
}
67
65
bench . end ( n ) ;
68
66
break ;
69
67
case 'string' :
70
68
bench . start ( ) ;
71
- for ( i = 0 ; i < n * 1024 ; i ++ ) {
69
+ for ( let i = 0 ; i < n * 1024 ; i ++ ) {
72
70
Buffer . from ( str ) ;
73
71
}
74
72
bench . end ( n ) ;
75
73
break ;
76
74
case 'string-utf8' :
77
75
bench . start ( ) ;
78
- for ( i = 0 ; i < n * 1024 ; i ++ ) {
76
+ for ( let i = 0 ; i < n * 1024 ; i ++ ) {
79
77
Buffer . from ( str , 'utf8' ) ;
80
78
}
81
79
bench . end ( n ) ;
82
80
break ;
83
81
case 'string-base64' :
84
82
bench . start ( ) ;
85
- for ( i = 0 ; i < n * 1024 ; i ++ ) {
83
+ for ( let i = 0 ; i < n * 1024 ; i ++ ) {
86
84
Buffer . from ( str , 'base64' ) ;
87
85
}
88
86
bench . end ( n ) ;
89
87
break ;
90
88
case 'object' :
91
89
bench . start ( ) ;
92
- for ( i = 0 ; i < n * 1024 ; i ++ ) {
90
+ for ( let i = 0 ; i < n * 1024 ; i ++ ) {
93
91
Buffer . from ( obj ) ;
94
92
}
95
93
bench . end ( n ) ;
96
94
break ;
97
95
default :
98
- assert . fail ( null , null , 'Should not get here' ) ;
96
+ assert . fail ( 'Should not get here' ) ;
99
97
}
100
98
}
0 commit comments