@@ -139,28 +139,22 @@ if (isInBrowser) {
139
139
} ;
140
140
}
141
141
142
- function assert ( b , m = "" ) {
143
- if ( ! b )
144
- throw new Error ( `Bad assertion: ${ m } ` ) ;
145
- }
146
-
147
-
148
142
function mean ( values ) {
149
- assert ( values instanceof Array ) ;
143
+ console . assert ( values instanceof Array ) ;
150
144
let sum = 0 ;
151
145
for ( let x of values )
152
146
sum += x ;
153
147
return sum / values . length ;
154
148
}
155
149
156
150
function geomeanScore ( values ) {
157
- assert ( values instanceof Array ) ;
151
+ console . assert ( values instanceof Array ) ;
158
152
let product = 1 ;
159
153
for ( let x of values )
160
154
product *= x ;
161
155
const score = product ** ( 1 / values . length ) ;
162
156
// Allow 0 for uninitialized subScores().
163
- assert ( score >= 0 , `Got invalid score: ${ score } ` )
157
+ console . assert ( score >= 0 , `Got invalid score: ${ score } ` )
164
158
return score ;
165
159
}
166
160
@@ -206,7 +200,7 @@ class ShellFileLoader {
206
200
// Cache / memoize previously read files, because some workloads
207
201
// share common code.
208
202
load ( url ) {
209
- assert ( ! isInBrowser ) ;
203
+ console . assert ( ! isInBrowser ) ;
210
204
if ( ! globalThis . prefetchResources )
211
205
return `load("${ url } ");`
212
206
@@ -230,7 +224,7 @@ class Driver {
230
224
// Make benchmark list unique and sort it.
231
225
this . benchmarks = Array . from ( new Set ( benchmarks ) ) ;
232
226
this . benchmarks . sort ( ( a , b ) => a . plan . name . toLowerCase ( ) < b . plan . name . toLowerCase ( ) ? 1 : - 1 ) ;
233
- assert ( this . benchmarks . length , "No benchmarks selected" ) ;
227
+ console . assert ( this . benchmarks . length , "No benchmarks selected" ) ;
234
228
// TODO: Cleanup / remove / merge `blobDataCache` and `loadCache` vs.
235
229
// the global `fileLoader` cache.
236
230
this . blobDataCache = { } ;
@@ -290,7 +284,7 @@ class Driver {
290
284
const allScores = [ ] ;
291
285
for ( const benchmark of this . benchmarks ) {
292
286
const score = benchmark . score ;
293
- assert ( score > 0 , `Invalid ${ benchmark . name } score: ${ score } ` ) ;
287
+ console . assert ( score > 0 , `Invalid ${ benchmark . name } score: ${ score } ` ) ;
294
288
allScores . push ( score ) ;
295
289
}
296
290
@@ -303,13 +297,13 @@ class Driver {
303
297
for ( const benchmark of this . benchmarks ) {
304
298
for ( let [ category , value ] of Object . entries ( benchmark . subScores ( ) ) ) {
305
299
const arr = categoryScores . get ( category ) ;
306
- assert ( value > 0 , `Invalid ${ benchmark . name } ${ category } score: ${ value } ` ) ;
300
+ console . assert ( value > 0 , `Invalid ${ benchmark . name } ${ category } score: ${ value } ` ) ;
307
301
arr . push ( value ) ;
308
302
}
309
303
}
310
304
311
305
const totalScore = geomeanScore ( allScores ) ;
312
- assert ( totalScore > 0 , `Invalid total score: ${ totalScore } ` ) ;
306
+ console . assert ( totalScore > 0 , `Invalid total score: ${ totalScore } ` ) ;
313
307
314
308
if ( isInBrowser ) {
315
309
const summaryElement = document . getElementById ( "result-summary" ) ;
@@ -635,13 +629,7 @@ class ShellScripts extends Scripts {
635
629
} else
636
630
globalObject = runString ( "" ) ;
637
631
638
- globalObject . console = {
639
- log : globalObject . print ,
640
- warn : ( e ) => { print ( "Warn: " + e ) ; } ,
641
- error : ( e ) => { print ( "Error: " + e ) ; } ,
642
- debug : ( e ) => { print ( "Debug: " + e ) ; } ,
643
- } ;
644
-
632
+ globalObject . console = console ;
645
633
globalObject . self = globalObject ;
646
634
globalObject . top = {
647
635
currentResolve,
@@ -660,7 +648,7 @@ class ShellScripts extends Scripts {
660
648
}
661
649
662
650
addWithURL ( url ) {
663
- assert ( false , "Should not reach here in CLI" ) ;
651
+ console . assert ( false , "Should not reach here in CLI" ) ;
664
652
}
665
653
}
666
654
@@ -821,7 +809,7 @@ class Benchmark {
821
809
scripts . add ( prerunCode ) ;
822
810
823
811
if ( ! isInBrowser ) {
824
- assert ( this . scripts && this . scripts . length === this . plan . files . length ) ;
812
+ console . assert ( this . scripts && this . scripts . length === this . plan . files . length ) ;
825
813
for ( const text of this . scripts )
826
814
scripts . add ( text ) ;
827
815
} else {
@@ -937,7 +925,7 @@ class Benchmark {
937
925
}
938
926
939
927
prefetchResourcesForBrowser ( ) {
940
- assert ( isInBrowser ) ;
928
+ console . assert ( isInBrowser ) ;
941
929
942
930
const promises = this . plan . files . map ( ( file ) => this . loadBlob ( "file" , null , file ) . then ( ( blobData ) => {
943
931
if ( ! globalThis . allIsGood )
@@ -970,7 +958,7 @@ class Benchmark {
970
958
}
971
959
972
960
async retryPrefetchResource ( type , prop , file ) {
973
- assert ( isInBrowser ) ;
961
+ console . assert ( isInBrowser ) ;
974
962
975
963
const counter = JetStream . counter ;
976
964
const blobData = JetStream . blobDataCache [ file ] ;
@@ -1006,7 +994,7 @@ class Benchmark {
1006
994
}
1007
995
1008
996
async retryPrefetchResourcesForBrowser ( ) {
1009
- assert ( isInBrowser ) ;
997
+ console . assert ( isInBrowser ) ;
1010
998
1011
999
const counter = JetStream . counter ;
1012
1000
for ( const resource of this . plan . files ) {
@@ -1027,12 +1015,12 @@ class Benchmark {
1027
1015
}
1028
1016
1029
1017
prefetchResourcesForShell ( ) {
1030
- assert ( ! isInBrowser ) ;
1018
+ console . assert ( ! isInBrowser ) ;
1031
1019
1032
- assert ( this . scripts === null , "This initialization should be called only once." ) ;
1020
+ console . assert ( this . scripts === null , "This initialization should be called only once." ) ;
1033
1021
this . scripts = this . plan . files . map ( file => shellFileLoader . load ( file ) ) ;
1034
1022
1035
- assert ( this . preloads === null , "This initialization should be called only once." ) ;
1023
+ console . assert ( this . preloads === null , "This initialization should be called only once." ) ;
1036
1024
this . preloads = Object . entries ( this . plan . preload ?? { } ) ;
1037
1025
}
1038
1026
@@ -1145,7 +1133,7 @@ class DefaultBenchmark extends Benchmark {
1145
1133
this . averageTime = null ;
1146
1134
this . averageScore = null ;
1147
1135
1148
- assert ( this . iterations > this . worstCaseCount ) ;
1136
+ console . assert ( this . iterations > this . worstCaseCount ) ;
1149
1137
}
1150
1138
1151
1139
processResults ( results ) {
@@ -1157,7 +1145,7 @@ class DefaultBenchmark extends Benchmark {
1157
1145
results = results . slice ( 1 ) ;
1158
1146
results . sort ( ( a , b ) => a < b ? 1 : - 1 ) ;
1159
1147
for ( let i = 0 ; i + 1 < results . length ; ++ i )
1160
- assert ( results [ i ] >= results [ i + 1 ] ) ;
1148
+ console . assert ( results [ i ] >= results [ i + 1 ] ) ;
1161
1149
1162
1150
const worstCase = [ ] ;
1163
1151
for ( let i = 0 ; i < this . worstCaseCount ; ++ i )
0 commit comments