@@ -34,15 +34,19 @@ function computeIsLittleEndian() {
34
34
}
35
35
36
36
const isLittleEndian = computeIsLittleEndian ( ) ;
37
+ let globalCounter = 0 ;
37
38
38
- function randomFileContents ( bytes = ( ( Math . random ( ) * 128 ) >>> 0 ) + 2056 ) {
39
- let result = new ArrayBuffer ( bytes ) ;
39
+ function randomFileContents ( ) {
40
+ const numBytes = ( globalCounter % 128 ) + 2056 ;
41
+ globalCounter ++ ;
42
+ let result = new ArrayBuffer ( numBytes ) ;
40
43
let view = new Uint8Array ( result ) ;
41
- for ( let i = 0 ; i < bytes ; ++ i )
42
- view [ i ] = ( Math . random ( ) * 255 ) >>> 0 ;
44
+ for ( let i = 0 ; i < numBytes ; ++ i )
45
+ view [ i ] = ( i + globalCounter ) % 255 ;
43
46
return new DataView ( result ) ;
44
47
}
45
48
49
+
46
50
class File {
47
51
constructor ( dataView , permissions ) {
48
52
this . _data = dataView ;
@@ -145,27 +149,30 @@ class Directory {
145
149
function setupDirectory ( ) {
146
150
const fs = new Directory ;
147
151
let dirs = [ fs ] ;
152
+ let counter = 0 ;
148
153
for ( let dir of dirs ) {
149
- for ( let i = 0 ; i < 8 ; ++ i ) {
150
- if ( dirs . length < 250 && Math . random ( ) >= 0.3 ) {
154
+ for ( let i = 0 ; i < 10 ; ++ i ) {
155
+ if ( dirs . length < 400 && ( counter % 3 ) <= 1 ) {
151
156
dirs . push ( dir . addDirectory ( `dir-${ i } ` ) ) ;
152
157
}
158
+ counter ++ ;
153
159
}
154
160
}
155
161
156
162
for ( let dir of dirs ) {
157
163
for ( let i = 0 ; i < 5 ; ++ i ) {
158
- if ( Math . random ( ) >= 0.6 ) {
164
+ if ( ( counter % 3 ) === 0 ) {
159
165
dir . addFile ( `file-${ i } ` , new File ( randomFileContents ( ) ) ) ;
160
166
}
167
+ counter ++ ;
161
168
}
162
169
}
163
170
164
171
return fs ;
165
172
}
166
173
167
174
class Benchmark {
168
- EXPECTED_FILE_COUNT = 411 ;
175
+ EXPECTED_FILE_COUNT = 666 ;
169
176
170
177
totalFileCount = 0 ;
171
178
lastFileHash = undefined ;
0 commit comments