//===--- IndexPathTest.swift ----------------------------------------------===// // // This source file is part of the Swift.org open source project // // Copyright (c) 2020 - 2021 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// import Foundation import TestsUtils let size = 200 let increasingIndexPath = indexPath(size) let decreasingIndexPath = indexPath(size, reversed: true) let increasingMaxMiddleIndexPath = indexPath(size, middle: size + 1) let increasingMinMiddleIndexPath = indexPath(size, middle: -1) let tags: [BenchmarkCategory] = [.validation, .api, .IndexPath] public let benchmarks = [ BenchmarkInfo( name: "IndexPath.Subscript.Mutation", runFunction: run_IndexPathSubscriptMutation, tags: tags, setUpFunction: { blackHole(increasingIndexPath) }), BenchmarkInfo( name: "IndexPath.Subscript.Range.Mutation", runFunction: run_IndexPathSubscriptRangeMutation, tags: tags, setUpFunction: { blackHole(increasingIndexPath) }), BenchmarkInfo( name: "IndexPath.Max", runFunction: run_IndexPathMax, tags: tags, setUpFunction: { blackHole(decreasingIndexPath) blackHole(increasingMaxMiddleIndexPath) blackHole(increasingIndexPath) }), BenchmarkInfo( name: "IndexPath.Min", runFunction: run_IndexPathMin, tags: tags, setUpFunction: { blackHole(increasingIndexPath) blackHole(increasingMinMiddleIndexPath) blackHole(decreasingIndexPath) }), ] func indexPath(_ size: Int, reversed: Bool = false) -> IndexPath { let indexes = Array(0.. IndexPath { var indexes = Array(0.. Void ) { for _ in 0..