Skip to content

[benchmark] Janitor Duty, Legacy Factor: A-C #20861

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Dec 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion benchmark/scripts/Benchmark_Driver
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ class BenchmarkDoctor(object):
num_samples = self._adjusted_1s_samples(r.samples.min)

def capped(s):
return min(s, 2048)
return min(s, 200)
run_args = [(capped(num_samples), 1), (capped(num_samples / 2), 2)]
opts = self.driver.args.optimization
opts = opts if isinstance(opts, list) else [opts]
Expand Down
8 changes: 4 additions & 4 deletions benchmark/scripts/test_Benchmark_Driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,18 +533,18 @@ def test_measure_10_independent_1s_benchmark_series(self):

Num-samples for Benchmark Driver are calibrated to be powers of two,
take measurements for approximately 1s
based on short initial runtime sampling. Capped at 2k samples.
based on short initial runtime sampling. Capped at 200 samples.
"""
driver = BenchmarkDriverMock(tests=['B1'], responses=([
# calibration run, returns a stand-in for PerformanceTestResult
(_run('B1', num_samples=3, num_iters=1,
verbose=True), _PTR(min=300))] +
# 5x i1 series, with 300 μs runtime its possible to take 4098
# samples/s, but it should be capped at 2k
([(_run('B1', num_samples=2048, num_iters=1,
([(_run('B1', num_samples=200, num_iters=1,
verbose=True, measure_memory=True), _PTR(min=300))] * 5) +
# 5x i2 series
([(_run('B1', num_samples=2048, num_iters=2,
([(_run('B1', num_samples=200, num_iters=2,
verbose=True, measure_memory=True), _PTR(min=300))] * 5)
))
doctor = BenchmarkDoctor(self.args, driver)
Expand All @@ -561,7 +561,7 @@ def test_measure_10_independent_1s_benchmark_series(self):
self.assert_contains(
['Calibrating num-samples for B1:',
'Runtime 300 μs yields 4096 adjusted samples per second.',
'Measuring B1, 5 x i1 (2048 samples), 5 x i2 (2048 samples)'],
'Measuring B1, 5 x i1 (200 samples), 5 x i2 (200 samples)'],
self.logs['debug'])

def test_benchmark_name_matches_capital_words_conventions(self):
Expand Down
4 changes: 2 additions & 2 deletions benchmark/single-source/Ackermann.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import TestsUtils
public let Ackermann = BenchmarkInfo(
name: "Ackermann",
runFunction: run_Ackermann,
tags: [.unstable, .algorithm])
tags: [.algorithm])

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

@inline(never)
public func run_Ackermann(_ N: Int) {
let (m, n) = (3, 9)
let (m, n) = (3, 6)
var result = 0
for _ in 1...N {
result = Ackermann(m, n)
Expand Down
13 changes: 3 additions & 10 deletions benchmark/single-source/AngryPhonebook.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,15 @@ import Foundation
public let AngryPhonebook = BenchmarkInfo(
name: "AngryPhonebook",
runFunction: run_AngryPhonebook,
tags: [.validation, .api, .String])
tags: [.validation, .api, .String],
legacyFactor: 7)

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

@inline(never)
public func run_AngryPhonebook(_ N: Int) {
Expand Down
6 changes: 2 additions & 4 deletions benchmark/single-source/AnyHashableWithAClass.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ public var AnyHashableWithAClass = BenchmarkInfo(
name: "AnyHashableWithAClass",
runFunction: run_AnyHashableWithAClass,
tags: [.abstraction, .runtime, .cpubench],
legacyFactor: lf
legacyFactor: 500
)

let lf = 500

class TestHashableBase : Hashable {
var value: Int
init(_ value: Int) {
Expand Down Expand Up @@ -58,7 +56,7 @@ class TestHashableDerived5 : TestHashableDerived4 {}
@inline(never)
public func run_AnyHashableWithAClass(_ N: Int) {
let c = TestHashableDerived5(10)
for _ in 0...(N*500000/lf) {
for _ in 0...(N*1000) {
_ = AnyHashable(c)
}
}
15 changes: 9 additions & 6 deletions benchmark/single-source/Array2D.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,25 @@ public let Array2D = BenchmarkInfo(
runFunction: run_Array2D,
tags: [.validation, .api, .Array],
setUpFunction: { blackHole(inputArray) },
tearDownFunction: { inputArray = nil })
tearDownFunction: { inputArray = nil },
legacyFactor: 16)

let size = 256

var inputArray: [[Int]]! = {
var A: [[Int]] = []
A.reserveCapacity(1024)
for _ in 0 ..< 1024 {
A.append(Array(0 ..< 1024))
A.reserveCapacity(size)
for _ in 0 ..< size {
A.append(Array(0 ..< size))
}
return A
}()

@inline(never)
func modifyArray(_ A: inout [[Int]], _ N: Int) {
for _ in 0..<N {
for i in 0 ..< 1024 {
for y in 0 ..< 1024 {
for i in 0 ..< size {
for y in 0 ..< size {
A[i][y] = A[i][y] + 1
A[i][y] = A[i][y] - 1
}
Expand Down
Loading