-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path192+Strides.swift
89 lines (69 loc) · 2.87 KB
/
192+Strides.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//=----------------------------------------------------------------------------=
// This source file is part of the AwesomeNumbersKit open source project.
//
// Copyright (c) 2022 Oscar Byström Ericsson
// Licensed under Apache License, Version 2.0
//
// See http://www.apache.org/licenses/LICENSE-2.0 for license information.
//=----------------------------------------------------------------------------=
#if !DEBUG
import ANKCoreKit
import ANKFullWidthKit
import XCTest
private typealias X = ANK.U192X64
private typealias Y = ANK.U192X32
//*============================================================================*
// MARK: * ANK x Int192 x Strides
//*============================================================================*
final class Int192BenchmarksOnStrides: XCTestCase {
typealias T = Int192
//=------------------------------------------------------------------------=
// MARK: Tests
//=------------------------------------------------------------------------=
func testAdvancedBy() {
var lhs = ANK.blackHoleIdentity(T(x64: X(~1, ~2, ~3)))
var rhs = ANK.blackHoleIdentity(Int.max)
for _ in 0 ..< 5_000_000 {
ANK.blackHole(lhs.advanced(by: rhs))
ANK.blackHoleInoutIdentity(&lhs)
ANK.blackHoleInoutIdentity(&rhs)
}
}
func testDistanceTo() {
var lhs = ANK.blackHoleIdentity(T(x64: X(~1, ~2, ~3)))
var rhs = ANK.blackHoleIdentity(T(x64: X(~1, ~2, ~3)).advanced(by: Int.max))
for _ in 0 ..< 5_000_000 {
ANK.blackHole(lhs.distance(to: rhs))
ANK.blackHoleInoutIdentity(&lhs)
ANK.blackHoleInoutIdentity(&rhs)
}
}
}
//*============================================================================*
// MARK: * ANK x UInt192 x Strides
//*============================================================================*
final class UInt192BenchmarksOnStrides: XCTestCase {
typealias T = UInt192
//=------------------------------------------------------------------------=
// MARK: Tests
//=------------------------------------------------------------------------=
func testAdvancedBy() {
var lhs = ANK.blackHoleIdentity(T(x64: X(~1, ~2, ~3)))
var rhs = ANK.blackHoleIdentity(Int.max)
for _ in 0 ..< 5_000_000 {
ANK.blackHole(lhs.advanced(by: rhs))
ANK.blackHoleInoutIdentity(&lhs)
ANK.blackHoleInoutIdentity(&rhs)
}
}
func testDistanceTo() {
var lhs = ANK.blackHoleIdentity(T(x64: X(~1, ~2, ~3)))
var rhs = ANK.blackHoleIdentity(T(x64: X(~1, ~2, ~3)).advanced(by: Int.max))
for _ in 0 ..< 5_000_000 {
ANK.blackHole(lhs.distance(to: rhs))
ANK.blackHoleInoutIdentity(&lhs)
ANK.blackHoleInoutIdentity(&rhs)
}
}
}
#endif