Skip to content

Commit ec836bd

Browse files
authored
Merge pull request #20861 from palimondo/a-tall-white-fountain-played
[benchmark] Janitor Duty, Legacy Factor: A-C
2 parents fab121e + 2121367 commit ec836bd

22 files changed

+230
-238
lines changed

benchmark/scripts/Benchmark_Driver

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ class BenchmarkDoctor(object):
496496
num_samples = self._adjusted_1s_samples(r.samples.min)
497497

498498
def capped(s):
499-
return min(s, 2048)
499+
return min(s, 200)
500500
run_args = [(capped(num_samples), 1), (capped(num_samples / 2), 2)]
501501
opts = self.driver.args.optimization
502502
opts = opts if isinstance(opts, list) else [opts]

benchmark/scripts/test_Benchmark_Driver.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -533,18 +533,18 @@ def test_measure_10_independent_1s_benchmark_series(self):
533533
534534
Num-samples for Benchmark Driver are calibrated to be powers of two,
535535
take measurements for approximately 1s
536-
based on short initial runtime sampling. Capped at 2k samples.
536+
based on short initial runtime sampling. Capped at 200 samples.
537537
"""
538538
driver = BenchmarkDriverMock(tests=['B1'], responses=([
539539
# calibration run, returns a stand-in for PerformanceTestResult
540540
(_run('B1', num_samples=3, num_iters=1,
541541
verbose=True), _PTR(min=300))] +
542542
# 5x i1 series, with 300 μs runtime its possible to take 4098
543543
# samples/s, but it should be capped at 2k
544-
([(_run('B1', num_samples=2048, num_iters=1,
544+
([(_run('B1', num_samples=200, num_iters=1,
545545
verbose=True, measure_memory=True), _PTR(min=300))] * 5) +
546546
# 5x i2 series
547-
([(_run('B1', num_samples=2048, num_iters=2,
547+
([(_run('B1', num_samples=200, num_iters=2,
548548
verbose=True, measure_memory=True), _PTR(min=300))] * 5)
549549
))
550550
doctor = BenchmarkDoctor(self.args, driver)
@@ -561,7 +561,7 @@ def test_measure_10_independent_1s_benchmark_series(self):
561561
self.assert_contains(
562562
['Calibrating num-samples for B1:',
563563
'Runtime 300 μs yields 4096 adjusted samples per second.',
564-
'Measuring B1, 5 x i1 (2048 samples), 5 x i2 (2048 samples)'],
564+
'Measuring B1, 5 x i1 (200 samples), 5 x i2 (200 samples)'],
565565
self.logs['debug'])
566566

567567
def test_benchmark_name_matches_capital_words_conventions(self):

benchmark/single-source/Ackermann.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import TestsUtils
1717
public let Ackermann = BenchmarkInfo(
1818
name: "Ackermann",
1919
runFunction: run_Ackermann,
20-
tags: [.unstable, .algorithm])
20+
tags: [.algorithm])
2121

2222
func ackermann(_ M: Int, _ N : Int) -> Int {
2323
if (M == 0) { return N + 1 }
@@ -39,7 +39,7 @@ let ref_result = [5, 13, 29, 61, 125, 253, 509, 1021, 2045, 4093, 8189, 16381, 3
3939

4040
@inline(never)
4141
public func run_Ackermann(_ N: Int) {
42-
let (m, n) = (3, 9)
42+
let (m, n) = (3, 6)
4343
var result = 0
4444
for _ in 1...N {
4545
result = Ackermann(m, n)

benchmark/single-source/AngryPhonebook.swift

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,15 @@ import Foundation
1818
public let AngryPhonebook = BenchmarkInfo(
1919
name: "AngryPhonebook",
2020
runFunction: run_AngryPhonebook,
21-
tags: [.validation, .api, .String])
21+
tags: [.validation, .api, .String],
22+
legacyFactor: 7)
2223

2324
var words = [
2425
"James", "John", "Robert", "Michael", "William", "David", "Richard", "Joseph",
2526
"Charles", "Thomas", "Christopher", "Daniel", "Matthew", "Donald", "Anthony",
2627
"Paul", "Mark", "George", "Steven", "Kenneth", "Andrew", "Edward", "Brian",
2728
"Joshua", "Kevin", "Ronald", "Timothy", "Jason", "Jeffrey", "Gary", "Ryan",
28-
"Nicholas", "Eric", "Stephen", "Jacob", "Larry", "Frank", "Jonathan", "Scott",
29-
"Justin", "Raymond", "Brandon", "Gregory", "Samuel", "Patrick", "Benjamin",
30-
"Jack", "Dennis", "Jerry", "Alexander", "Tyler", "Douglas", "Henry", "Peter",
31-
"Walter", "Aaron", "Jose", "Adam", "Harold", "Zachary", "Nathan", "Carl",
32-
"Kyle", "Arthur", "Gerald", "Lawrence", "Roger", "Albert", "Keith", "Jeremy",
33-
"Terry", "Joe", "Sean", "Willie", "Jesse", "Ralph", "Billy", "Austin", "Bruce",
34-
"Christian", "Roy", "Bryan", "Eugene", "Louis", "Harry", "Wayne", "Ethan",
35-
"Jordan", "Russell", "Alan", "Philip", "Randy", "Juan", "Howard", "Vincent",
36-
"Bobby", "Dylan", "Johnny", "Phillip", "Craig"]
29+
"Nicholas", "Eric", "Stephen", "Jacob", "Larry", "Frank"]
3730

3831
@inline(never)
3932
public func run_AngryPhonebook(_ N: Int) {

benchmark/single-source/AnyHashableWithAClass.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,9 @@ public var AnyHashableWithAClass = BenchmarkInfo(
2626
name: "AnyHashableWithAClass",
2727
runFunction: run_AnyHashableWithAClass,
2828
tags: [.abstraction, .runtime, .cpubench],
29-
legacyFactor: lf
29+
legacyFactor: 500
3030
)
3131

32-
let lf = 500
33-
3432
class TestHashableBase : Hashable {
3533
var value: Int
3634
init(_ value: Int) {
@@ -58,7 +56,7 @@ class TestHashableDerived5 : TestHashableDerived4 {}
5856
@inline(never)
5957
public func run_AnyHashableWithAClass(_ N: Int) {
6058
let c = TestHashableDerived5(10)
61-
for _ in 0...(N*500000/lf) {
59+
for _ in 0...(N*1000) {
6260
_ = AnyHashable(c)
6361
}
6462
}

benchmark/single-source/Array2D.swift

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,25 @@ public let Array2D = BenchmarkInfo(
1717
runFunction: run_Array2D,
1818
tags: [.validation, .api, .Array],
1919
setUpFunction: { blackHole(inputArray) },
20-
tearDownFunction: { inputArray = nil })
20+
tearDownFunction: { inputArray = nil },
21+
legacyFactor: 16)
22+
23+
let size = 256
2124

2225
var inputArray: [[Int]]! = {
2326
var A: [[Int]] = []
24-
A.reserveCapacity(1024)
25-
for _ in 0 ..< 1024 {
26-
A.append(Array(0 ..< 1024))
27+
A.reserveCapacity(size)
28+
for _ in 0 ..< size {
29+
A.append(Array(0 ..< size))
2730
}
2831
return A
2932
}()
3033

3134
@inline(never)
3235
func modifyArray(_ A: inout [[Int]], _ N: Int) {
3336
for _ in 0..<N {
34-
for i in 0 ..< 1024 {
35-
for y in 0 ..< 1024 {
37+
for i in 0 ..< size {
38+
for y in 0 ..< size {
3639
A[i][y] = A[i][y] + 1
3740
A[i][y] = A[i][y] - 1
3841
}

0 commit comments

Comments
 (0)