Skip to content

Commit 9e10a1b

Browse files
committed
[4.2][benchmark] RandomIntegersLCG: Fix result check on 32-bit platforms
Values returned by random APIs depend on the bitWidth of the underlying integer type; make sure we use a consistent integer width when expecting particular results. (cherry picked from commit d66d6b4)
1 parent 9b892e0 commit 9e10a1b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

benchmark/single-source/RandomValues.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ public func run_RandomIntegersDef(_ N: Int) {
5454
@inline(never)
5555
public func run_RandomIntegersLCG(_ N: Int) {
5656
for _ in 0 ..< N {
57-
var x = 0
57+
var x: Int64 = 0
5858
var generator = LCRNG(seed: 0)
5959
for _ in 0 ..< 100_000 {
60-
x &+= Int.random(in: 0...10_000, using: &generator)
60+
x &+= Int64.random(in: 0...10_000, using: &generator)
6161
}
6262
CheckResults(x == 498214315)
6363
}

0 commit comments

Comments
 (0)