@@ -426,39 +426,39 @@ func runBench(_ test: BenchmarkInfo, _ c: TestConfig) -> BenchResults? {
426
426
test. setUpFunction ? ( )
427
427
428
428
for s in 0 ..< c. numSamples {
429
- var scale : Int
430
- var elapsed_time : Int = 0
429
+ var numIters : Int
430
+ var time : Int = 0
431
431
if c. fixedNumIters == 0 {
432
- elapsed_time = sampler. measure ( test. name, fn: testFn, numIters: 1 )
432
+ time = sampler. measure ( test. name, fn: testFn, numIters: 1 )
433
433
434
- if elapsed_time > 0 {
434
+ if time > 0 {
435
435
let usPerSecond = 1_000_000.0 // microseconds (μs)
436
436
let timePerSample = Int ( c. sampleTime * usPerSecond)
437
437
/// Number of iterations to make `testFn` run for the desired time.
438
- scale = timePerSample / elapsed_time
438
+ numIters = timePerSample / time
439
439
} else {
440
440
logVerbose ( " Warning: elapsed time is 0! " )
441
- scale = 1
441
+ numIters = 1
442
442
}
443
443
} else {
444
444
// Compute the scaling factor if a fixed c.fixedNumIters is not specified.
445
- scale = c. fixedNumIters
446
- if scale == 1 {
447
- elapsed_time = sampler. measure ( test. name, fn: testFn, numIters: 1 )
445
+ numIters = c. fixedNumIters
446
+ if numIters == 1 {
447
+ time = sampler. measure ( test. name, fn: testFn, numIters: 1 )
448
448
}
449
449
}
450
450
// Make integer overflow less likely on platforms where Int is 32 bits wide.
451
451
// FIXME: Switch BenchmarkInfo to use Int64 for the iteration scale, or fix
452
452
// benchmarks to not let scaling get off the charts.
453
- scale = min ( scale , Int . max / 10_000 )
453
+ numIters = min ( numIters , Int . max / 10_000 )
454
454
455
455
// Rerun the test with the computed scale factor.
456
- if scale > 1 {
457
- logVerbose ( " Measuring with scale \( scale ) . " )
458
- elapsed_time = sampler. measure ( test. name, fn: testFn, numIters: scale )
456
+ if numIters > 1 {
457
+ logVerbose ( " Measuring with scale \( numIters ) . " )
458
+ time = sampler. measure ( test. name, fn: testFn, numIters: numIters )
459
459
}
460
460
461
- samples [ s] = elapsed_time
461
+ samples [ s] = time
462
462
logVerbose ( " Sample \( s) , \( samples [ s] ) " )
463
463
}
464
464
test. tearDownFunction ? ( )
0 commit comments