|
| 1 | +//===--- ContiguousArrayTests.swift ---------------------------------------===// |
| 2 | +// |
| 3 | +// This source file is part of the Swift.org open source project |
| 4 | +// |
| 5 | +// Copyright (c) 2025 Apple Inc. and the Swift project authors |
| 6 | +// Licensed under Apache License v2.0 with Runtime Library Exception |
| 7 | +// |
| 8 | +// See https://swift.org/LICENSE.txt for license information |
| 9 | +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors |
| 10 | +// |
| 11 | +//===----------------------------------------------------------------------===// |
| 12 | + |
| 13 | +import TestsUtils |
| 14 | + |
| 15 | +public let benchmarks = [ |
| 16 | + BenchmarkInfo(name: "ContiguousArrayEqualUnique", runFunction: run_ContiguousArrayEqualUnique, tags: [.validation, .api, .Array]), |
| 17 | + BenchmarkInfo(name: "ContiguousArrayEqualShared", runFunction: run_ContiguousArrayEqualShared, tags: [.validation, .api, .Array]), |
| 18 | + BenchmarkInfo(name: "ContiguousArrayIdentical", runFunction: run_ContiguousArrayIdentical, tags: [.validation, .api, .Array]), |
| 19 | +] |
| 20 | + |
| 21 | +@inline(never) |
| 22 | +public func run_ContiguousArrayEqualUnique(_ n: Int) { |
| 23 | + let a1 = ContiguousArray(0 ..< n) |
| 24 | + let a2 = ContiguousArray(0 ..< n) |
| 25 | + for _ in 0 ..< 100_000 { |
| 26 | + check(a1 == a2) |
| 27 | + } |
| 28 | +} |
| 29 | + |
| 30 | +@inline(never) |
| 31 | +public func run_ContiguousArrayEqualShared(_ n: Int) { |
| 32 | + let a1 = ContiguousArray(0 ..< n) |
| 33 | + let a2 = a1 |
| 34 | + for _ in 0 ..< 100_000 { |
| 35 | + check(a1 == a2) |
| 36 | + } |
| 37 | +} |
| 38 | + |
| 39 | +@inline(never) |
| 40 | +public func run_ContiguousArrayIdentical(_ n: Int) { |
| 41 | + let a1 = ContiguousArray(0 ..< n) |
| 42 | + let a2 = a1 |
| 43 | + for _ in 0 ..< 100_000 { |
| 44 | + check(a1.isIdentical(to: a2)) |
| 45 | + } |
| 46 | +} |
0 commit comments