Added benchmarks corresponding to those previously found in `SurgeTests/ArithmeticTests.swift`
This commit is contained in:
parent
370b71514b
commit
c41d6044f6
|
@ -91,6 +91,7 @@
|
|||
CAAF5000233A701A00CC0AA7 /* LogarithmTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAAF4FFF233A701A00CC0AA7 /* LogarithmTests.swift */; };
|
||||
CAAF500C233A7B6700CC0AA7 /* Surge.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 614AD31F1FC0AD99002BFE1C /* Surge.framework */; };
|
||||
CAAF5001233A701A00CC0AA7 /* LogarithmTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAAF4FFF233A701A00CC0AA7 /* LogarithmTests.swift */; };
|
||||
CAAF5015233A7D4100CC0AA7 /* ArithmeticTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAAF5014233A7C7900CC0AA7 /* ArithmeticTests.swift */; };
|
||||
CAAF501A233A9E6300CC0AA7 /* XCTestCase+Surge.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAAF5019233A9E6300CC0AA7 /* XCTestCase+Surge.swift */; };
|
||||
CAAF5002233A701A00CC0AA7 /* LogarithmTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAAF4FFF233A701A00CC0AA7 /* LogarithmTests.swift */; };
|
||||
CAEC79BF2319274F00516E10 /* OperatorPrecedences.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAEC79B72319244D00516E10 /* OperatorPrecedences.swift */; };
|
||||
|
@ -187,6 +188,7 @@
|
|||
CAAF4FFF233A701A00CC0AA7 /* LogarithmTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LogarithmTests.swift; sourceTree = "<group>"; };
|
||||
CAAF5007233A7B6700CC0AA7 /* SurgeBenchmarkTests-macOS.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "SurgeBenchmarkTests-macOS.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
CAAF500B233A7B6700CC0AA7 /* Info-BenchmarkTests.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Info-BenchmarkTests.plist"; sourceTree = "<group>"; };
|
||||
CAAF5014233A7C7900CC0AA7 /* ArithmeticTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArithmeticTests.swift; sourceTree = "<group>"; };
|
||||
CAAF5019233A9E6300CC0AA7 /* XCTestCase+Surge.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "XCTestCase+Surge.swift"; sourceTree = "<group>"; };
|
||||
CAEC79B72319244D00516E10 /* OperatorPrecedences.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OperatorPrecedences.swift; sourceTree = "<group>"; };
|
||||
CAEC79C323192FE300516E10 /* Scalar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Scalar.swift; sourceTree = "<group>"; };
|
||||
|
@ -311,6 +313,7 @@
|
|||
CAAF5008233A7B6700CC0AA7 /* SurgeBenchmarkTests */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
CAAF5014233A7C7900CC0AA7 /* ArithmeticTests.swift */,
|
||||
CAAF5019233A9E6300CC0AA7 /* XCTestCase+Surge.swift */,
|
||||
);
|
||||
path = SurgeBenchmarkTests;
|
||||
|
@ -938,6 +941,7 @@
|
|||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
CAAF501A233A9E6300CC0AA7 /* XCTestCase+Surge.swift in Sources */,
|
||||
CAAF5015233A7D4100CC0AA7 /* ArithmeticTests.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
|
@ -0,0 +1,314 @@
|
|||
// Copyright © 2014-2018 the Surge contributors
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
import Foundation
|
||||
import XCTest
|
||||
|
||||
@testable import Surge
|
||||
|
||||
class ArithmeticTests: XCTestCase {
|
||||
static let n = 100_000
|
||||
|
||||
// MARK: - Addition: In Place
|
||||
|
||||
func test_add_in_place_array_array_float() {
|
||||
measure_inout_array_array(of: Float.self) { measure in
|
||||
measureMetrics([.wallClockTime], automaticallyStartMeasuring: false) {
|
||||
measure(Surge.addInPlace)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func test_add_in_place_array_array_double() {
|
||||
measure_inout_array_array(of: Double.self) { measure in
|
||||
measureMetrics([.wallClockTime], automaticallyStartMeasuring: false) {
|
||||
measure(Surge.addInPlace)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Subtraction: In Place
|
||||
|
||||
func test_sub_in_place_array_array_float() {
|
||||
measure_inout_array_array(of: Float.self) { measure in
|
||||
measureMetrics([.wallClockTime], automaticallyStartMeasuring: false) {
|
||||
measure(Surge.subInPlace)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func test_sub_in_place_array_array_double() {
|
||||
measure_inout_array_array(of: Double.self) { measure in
|
||||
measureMetrics([.wallClockTime], automaticallyStartMeasuring: false) {
|
||||
measure(Surge.subInPlace)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Multiplication: In Place
|
||||
|
||||
func test_mul_in_place_array_array_float() {
|
||||
measure_inout_array_array(of: Float.self) { measure in
|
||||
measureMetrics([.wallClockTime], automaticallyStartMeasuring: false) {
|
||||
measure(Surge.mulInPlace)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func test_mul_in_place_array_array_double() {
|
||||
measure_inout_array_array(of: Double.self) { measure in
|
||||
measureMetrics([.wallClockTime], automaticallyStartMeasuring: false) {
|
||||
measure(Surge.mulInPlace)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Division: In Place
|
||||
|
||||
func test_div_in_place_array_array_float() {
|
||||
measure_inout_array_array(of: Float.self) { measure in
|
||||
measureMetrics([.wallClockTime], automaticallyStartMeasuring: false) {
|
||||
measure(Surge.divInPlace)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func test_div_in_place_array_array_double() {
|
||||
measure_inout_array_array(of: Double.self) { measure in
|
||||
measureMetrics([.wallClockTime], automaticallyStartMeasuring: false) {
|
||||
measure(Surge.divInPlace)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Modulo: In Place
|
||||
|
||||
func test_mod_in_place_array_array_float() {
|
||||
measure_inout_array_array(of: Double.self) { measure in
|
||||
measureMetrics([.wallClockTime], automaticallyStartMeasuring: false) {
|
||||
measure(Surge.modInPlace)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func test_mod_in_place_array_array_double() {
|
||||
measure_inout_array_array(of: Double.self) { measure in
|
||||
measureMetrics([.wallClockTime], automaticallyStartMeasuring: false) {
|
||||
measure(Surge.modInPlace)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Remainder
|
||||
|
||||
func test_remainder_in_place_array_array_float() {
|
||||
measure_inout_array_array(of: Float.self) { measure in
|
||||
measureMetrics([.wallClockTime], automaticallyStartMeasuring: false) {
|
||||
measure(Surge.remainderInPlace)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func test_remainder_in_place_array_array_double() {
|
||||
measure_inout_array_array(of: Double.self) { measure in
|
||||
measureMetrics([.wallClockTime], automaticallyStartMeasuring: false) {
|
||||
measure(Surge.remainderInPlace)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Exponential
|
||||
|
||||
func test_exp_in_place_array_float() {
|
||||
measure_inout_array(of: Float.self) { measure in
|
||||
measureMetrics([.wallClockTime], automaticallyStartMeasuring: false) {
|
||||
measure(Surge.expInPlace)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func test_exp_in_place_array_double() {
|
||||
measure_inout_array(of: Double.self) { measure in
|
||||
measureMetrics([.wallClockTime], automaticallyStartMeasuring: false) {
|
||||
measure(Surge.expInPlace)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Square Exponentiation
|
||||
|
||||
func test_exp2_in_place_array_float() {
|
||||
measure_inout_array(of: Double.self) { measure in
|
||||
measureMetrics([.wallClockTime], automaticallyStartMeasuring: false) {
|
||||
measure(Surge.exp2InPlace)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func test_exp2_in_place_array_double() {
|
||||
measure_inout_array(of: Float.self) { measure in
|
||||
measureMetrics([.wallClockTime], automaticallyStartMeasuring: false) {
|
||||
measure(Surge.exp2InPlace)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Power
|
||||
|
||||
func test_pow_in_place_array_array_float() {
|
||||
measure_inout_array_array(of: Float.self) { measure in
|
||||
measureMetrics([.wallClockTime], automaticallyStartMeasuring: false) {
|
||||
measure(Surge.powInPlace)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func test_pow_in_place_array_array_double() {
|
||||
measure_inout_array_array(of: Double.self) { measure in
|
||||
measureMetrics([.wallClockTime], automaticallyStartMeasuring: false) {
|
||||
measure(Surge.powInPlace)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func test_pow_in_place_array_scalar_float() {
|
||||
measure_inout_array_scalar(of: Float.self) { measure in
|
||||
measureMetrics([.wallClockTime], automaticallyStartMeasuring: false) {
|
||||
measure(Surge.powInPlace)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func test_pow_in_place_array_scalar_double() {
|
||||
measure_inout_array_scalar(of: Double.self) { measure in
|
||||
measureMetrics([.wallClockTime], automaticallyStartMeasuring: false) {
|
||||
measure(Surge.powInPlace)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Square
|
||||
|
||||
func test_sq_array_float() {
|
||||
measure_inout_array(of: Float.self) { measure in
|
||||
measureMetrics([.wallClockTime], automaticallyStartMeasuring: false) {
|
||||
measure(Surge.sqInPlace)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func test_sq_array_double() {
|
||||
measure_inout_array(of: Double.self) { measure in
|
||||
measureMetrics([.wallClockTime], automaticallyStartMeasuring: false) {
|
||||
measure(Surge.sqInPlace)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Square Root
|
||||
|
||||
func test_sqrt_array_array_float() {
|
||||
measure_inout_array(of: Float.self) { measure in
|
||||
measureMetrics([.wallClockTime], automaticallyStartMeasuring: false) {
|
||||
measure(Surge.sqrtInPlace)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func test_sqrt_array_array_double() {
|
||||
measure_inout_array(of: Double.self) { measure in
|
||||
measureMetrics([.wallClockTime], automaticallyStartMeasuring: false) {
|
||||
measure(Surge.sqrtInPlace)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Dot Product
|
||||
|
||||
func test_dot_array_array_float() {
|
||||
measure_array_array(of: Float.self) { measure in
|
||||
measureMetrics([.wallClockTime], automaticallyStartMeasuring: false) {
|
||||
measure(Surge.dot)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func test_dot_array_array_double() {
|
||||
measure_array_array(of: Float.self) { measure in
|
||||
measureMetrics([.wallClockTime], automaticallyStartMeasuring: false) {
|
||||
measure(Surge.dot)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Summation
|
||||
|
||||
func test_sum_array_float() {
|
||||
measure_array(of: Float.self) { measure in
|
||||
measureMetrics([.wallClockTime], automaticallyStartMeasuring: false) {
|
||||
measure(Surge.sum)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func test_sum_array_double() {
|
||||
measure_array(of: Double.self) { measure in
|
||||
measureMetrics([.wallClockTime], automaticallyStartMeasuring: false) {
|
||||
measure(Surge.sum)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Distance
|
||||
|
||||
func test_dist_array_array_float() {
|
||||
measure_array_array(of: Float.self) { measure in
|
||||
measureMetrics([.wallClockTime], automaticallyStartMeasuring: false) {
|
||||
measure(Surge.dist)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func test_dist_array_array_double() {
|
||||
measure_array_array(of: Double.self) { measure in
|
||||
measureMetrics([.wallClockTime], automaticallyStartMeasuring: false) {
|
||||
measure(Surge.dist)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Distance Squared
|
||||
|
||||
func test_distsq_array_array_float() {
|
||||
measure_array_array(of: Float.self) { measure in
|
||||
measureMetrics([.wallClockTime], automaticallyStartMeasuring: false) {
|
||||
measure(Surge.distSq)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func test_distsq_array_array_double() {
|
||||
measure_array_array(of: Double.self) { measure in
|
||||
measureMetrics([.wallClockTime], automaticallyStartMeasuring: false) {
|
||||
measure(Surge.distSq)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue