Skip to content

Commit 91f25f6

Browse files
committed
[benchmark] RandomValues Legacy Factor
1 parent 8cb6130 commit 91f25f6

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

benchmark/single-source/RandomValues.swift

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,25 @@ import TestsUtils
1919
//
2020

2121
public let RandomValues = [
22-
BenchmarkInfo(name: "RandomIntegersDef", runFunction: run_RandomIntegersDef, tags: [.api]),
23-
BenchmarkInfo(name: "RandomIntegersLCG", runFunction: run_RandomIntegersLCG, tags: [.api]),
24-
BenchmarkInfo(name: "RandomDoubleDef", runFunction: run_RandomDoubleDef, tags: [.api]),
25-
BenchmarkInfo(name: "RandomDoubleLCG", runFunction: run_RandomDoubleLCG, tags: [.api]),
22+
BenchmarkInfo(name: "RandomIntegersDef", runFunction: run_RandomIntegersDef,
23+
tags: [.api], legacyFactor: 100),
24+
BenchmarkInfo(name: "RandomIntegersLCG", runFunction: run_RandomIntegersLCG,
25+
tags: [.api]),
26+
BenchmarkInfo(name: "RandomDoubleDef", runFunction: run_RandomDoubleDef,
27+
tags: [.api], legacyFactor: 100),
28+
BenchmarkInfo(name: "RandomDoubleLCG", runFunction: run_RandomDoubleLCG,
29+
tags: [.api], legacyFactor: 2),
2630
]
2731

2832
/// A linear congruential PRNG.
2933
struct LCRNG: RandomNumberGenerator {
3034
private var state: UInt64
31-
35+
3236
init(seed: Int) {
3337
state = UInt64(truncatingIfNeeded: seed)
3438
for _ in 0..<10 { _ = next() }
3539
}
36-
40+
3741
mutating func next() -> UInt64 {
3842
state = 2862933555777941757 &* state &+ 3037000493
3943
return state
@@ -44,7 +48,7 @@ struct LCRNG: RandomNumberGenerator {
4448
public func run_RandomIntegersDef(_ N: Int) {
4549
for _ in 0 ..< N {
4650
var x = 0
47-
for _ in 0 ..< 100_000 {
51+
for _ in 0 ..< 1_000 {
4852
x &+= Int.random(in: 0...10_000)
4953
}
5054
blackHole(x)
@@ -67,7 +71,7 @@ public func run_RandomIntegersLCG(_ N: Int) {
6771
public func run_RandomDoubleDef(_ N: Int) {
6872
for _ in 0 ..< N {
6973
var x = 0.0
70-
for _ in 0 ..< 100_000 {
74+
for _ in 0 ..< 1_000 {
7175
x += Double.random(in: -1000...1000)
7276
}
7377
blackHole(x)
@@ -79,7 +83,7 @@ public func run_RandomDoubleLCG(_ N: Int) {
7983
for _ in 0 ..< N {
8084
var x = 0.0
8185
var generator = LCRNG(seed: 0)
82-
for _ in 0 ..< 100_000 {
86+
for _ in 0 ..< 50_000 {
8387
x += Double.random(in: -1000...1000, using: &generator)
8488
}
8589
blackHole(x)

0 commit comments

Comments
 (0)