-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathANKSigned.swift
57 lines (44 loc) · 1.77 KB
/
ANKSigned.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
//=----------------------------------------------------------------------------=
// 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 ANKSignedKit
import XCTest
//*============================================================================*
// MARK: * ANK x Signed
//*============================================================================*
final class ANKSignedBenchmarks: XCTestCase {
typealias T = ANKSigned<UInt256>
typealias D = ANKSigned<UInt>
//=------------------------------------------------------------------------=
// MARK: Tests x Normalization
//=------------------------------------------------------------------------=
func testIsNormal() {
var abc = ANK.blackHoleIdentity(T(0, as: .plus ))
var xyz = ANK.blackHoleIdentity(T(0, as: .minus))
for _ in 0 ..< 1_000_000 {
ANK.blackHole(abc.isNormal)
ANK.blackHole(xyz.isNormal)
ANK.blackHoleInoutIdentity(&abc)
ANK.blackHoleInoutIdentity(&xyz)
}
}
func testNormalizedSign() {
var abc = ANK.blackHoleIdentity(T(0, as: .plus ))
var xyz = ANK.blackHoleIdentity(T(0, as: .minus))
for _ in 0 ..< 1_000_000 {
ANK.blackHole(abc.normalizedSign)
ANK.blackHole(xyz.normalizedSign)
ANK.blackHoleInoutIdentity(&abc)
ANK.blackHoleInoutIdentity(&xyz)
}
}
}
#endif