Skip to content

Commit 435e55f

Browse files
committed
[benchmark] Legacy factor ArrayOf[Generic]Ref
Lowered the base workload by a factor of 10
1 parent 04d1384 commit 435e55f

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

benchmark/single-source/ArrayOfGenericRef.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@
1313
// This benchmark tests creation and destruction of an array of enum
1414
// and generic type bound to nontrivial types.
1515
//
16-
// For comparison, we always create three arrays of 10,000 words.
16+
// For comparison, we always create three arrays of 1,000 words.
1717

1818
import TestsUtils
1919

2020
public let ArrayOfGenericRef = BenchmarkInfo(
2121
name: "ArrayOfGenericRef",
2222
runFunction: run_ArrayOfGenericRef,
23-
tags: [.validation, .api, .Array])
23+
tags: [.validation, .api, .Array],
24+
legacyFactor: 10)
2425

2526
protocol Constructible {
2627
associatedtype Element
@@ -31,8 +32,8 @@ class ConstructibleArray<T:Constructible> {
3132

3233
init(_ e:T.Element) {
3334
array = [T]()
34-
array.reserveCapacity(10_000)
35-
for _ in 0...10_000 {
35+
array.reserveCapacity(1_000)
36+
for _ in 0...1_000 {
3637
array.append(T(e:e) as T)
3738
}
3839
}
@@ -65,7 +66,7 @@ func genCommonRefArray() {
6566
class RefArray<T> {
6667
var array: [T]
6768

68-
init(_ i:T, count:Int = 10_000) {
69+
init(_ i:T, count:Int = 1_000) {
6970
array = [T](repeating: i, count: count)
7071
}
7172
}

benchmark/single-source/ArrayOfRef.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@
1414
// references. It is meant to be a baseline for comparison against
1515
// ArrayOfGenericRef.
1616
//
17-
// For comparison, we always create four arrays of 10,000 words.
17+
// For comparison, we always create four arrays of 1,000 words.
1818

1919
import TestsUtils
2020

2121
public let ArrayOfRef = BenchmarkInfo(
2222
name: "ArrayOfRef",
2323
runFunction: run_ArrayOfRef,
24-
tags: [.validation, .api, .Array])
24+
tags: [.validation, .api, .Array],
25+
legacyFactor: 10)
2526

2627
protocol Constructible {
2728
associatedtype Element
@@ -32,8 +33,8 @@ class ConstructibleArray<T:Constructible> {
3233

3334
init(_ e:T.Element) {
3435
array = [T]()
35-
array.reserveCapacity(10_000)
36-
for _ in 0...10_000 {
36+
array.reserveCapacity(1_000)
37+
for _ in 0...1_000 {
3738
array.append(T(e:e) as T)
3839
}
3940
}
@@ -77,7 +78,7 @@ enum RefEnum {
7778
class RefArray<T> {
7879
var array : [T]
7980

80-
init(_ i:T, count:Int = 10_000) {
81+
init(_ i:T, count:Int = 1_000) {
8182
array = [T](repeating: i, count: count)
8283
}
8384
}

0 commit comments

Comments
 (0)