Extend performance tests
This commit is contained in:
parent
4adfd85fb1
commit
6effdbb836
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// ComponentPerformanceTests.swift
|
||||
// ComponentIdentifierTests.swift
|
||||
// FirebladeECSPerformanceTests
|
||||
//
|
||||
// Created by Christian Treffs on 14.02.19.
|
||||
|
|
@ -8,9 +8,11 @@
|
|||
import FirebladeECS
|
||||
import XCTest
|
||||
|
||||
class ComponentTests: XCTestCase {
|
||||
class ComponentIdentifierTests: XCTestCase {
|
||||
|
||||
/// debug: 0.456 sec
|
||||
func testMeasureStaticComponentIdentifier() {
|
||||
let number: Int = 10_000
|
||||
let number: Int = 1_000_000
|
||||
measure {
|
||||
for _ in 0..<number {
|
||||
let id = Position.identifier
|
||||
|
|
@ -19,8 +21,9 @@ class ComponentTests: XCTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
/// debug: 0.413 sec
|
||||
func testMeasureComponentIdentifier() {
|
||||
let number: Int = 10_000
|
||||
let number: Int = 1_000_000
|
||||
let pos = Position(x: 1, y: 2)
|
||||
measure {
|
||||
for _ in 0..<number {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,16 @@
|
|||
import FirebladeECS
|
||||
import XCTest
|
||||
|
||||
#if DEBUG
|
||||
let isDebug: Bool = true
|
||||
#else
|
||||
let isDebug: Bool = false
|
||||
#endif
|
||||
|
||||
class HashingPerformanceTests: XCTestCase {
|
||||
|
||||
/// release: 0.726 sec
|
||||
/// debug: 3.179 sec
|
||||
func testMeasureCombineHash() {
|
||||
let a: Set<Int> = Set<Int>([14_561_291, 26_451_562, 34_562_182, 488_972_556, 5_128_426_962, 68_211_812])
|
||||
let b: Set<Int> = Set<Int>([1_083_838, 912_312, 83_333, 71_234_555, 4_343_234])
|
||||
|
|
@ -23,6 +32,8 @@ class HashingPerformanceTests: XCTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
/// release: 0.494 sec
|
||||
/// debug: 1.026 sec
|
||||
func testMeasureSetOfSetHash() {
|
||||
let a: Set<Int> = Set<Int>([14_561_291, 26_451_562, 34_562_182, 488_972_556, 5_128_426_962, 68_211_812])
|
||||
let b: Set<Int> = Set<Int>([1_083_838, 912_312, 83_333, 71_234_555, 4_343_234])
|
||||
|
|
@ -36,4 +47,58 @@ class HashingPerformanceTests: XCTestCase {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// release: 0.098 sec
|
||||
/// debug: 16.702 sec
|
||||
func testMeasureBernsteinDjb2() throws {
|
||||
try XCTSkipIf(isDebug)
|
||||
let string = "The quick brown fox jumps over the lazy dog"
|
||||
measure {
|
||||
for _ in 0..<1_000_000 {
|
||||
let hash = StringHashing.bernstein_djb2(string)
|
||||
_ = hash
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// release: 0.087 sec
|
||||
/// debug: 2.613 sec
|
||||
func testMeasureSingerDjb2() throws {
|
||||
let string = "The quick brown fox jumps over the lazy dog"
|
||||
measure {
|
||||
for _ in 0..<1_000_000 {
|
||||
let hash = StringHashing.singer_djb2(string)
|
||||
_ = hash
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// release: 0.088 sec
|
||||
/// debug: 30.766 sec
|
||||
func testMeasureSDBM() throws {
|
||||
try XCTSkipIf(isDebug)
|
||||
let string = "The quick brown fox jumps over the lazy dog"
|
||||
measure {
|
||||
for _ in 0..<1_000_000 {
|
||||
let hash = StringHashing.sdbm(string)
|
||||
_ = hash
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// release: 0.036 sec
|
||||
/// debug: 0.546 sec
|
||||
func testMeasureSwiftHasher() throws {
|
||||
try XCTSkipIf(isDebug)
|
||||
let string = "The quick brown fox jumps over the lazy dog"
|
||||
measure {
|
||||
for _ in 0..<1_000_000 {
|
||||
var hasher = Hasher()
|
||||
hasher.combine(string)
|
||||
let hash = hasher.finalize()
|
||||
_ = hash
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,12 +5,14 @@
|
|||
// Created by Christian Treffs on 05.10.19.
|
||||
//
|
||||
|
||||
import FirebladeECS
|
||||
import XCTest
|
||||
|
||||
final class TypeIdentifierPerformanceTests: XCTestCase {
|
||||
let maxIterations: Int = 100_000
|
||||
|
||||
// 0.056 sec
|
||||
// release: 0.000 sec
|
||||
// debug: 0.051 sec
|
||||
func testPerformanceObjectIdentifier() {
|
||||
measure {
|
||||
for _ in 0..<maxIterations {
|
||||
|
|
@ -25,7 +27,24 @@ final class TypeIdentifierPerformanceTests: XCTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
// 1.451 sec
|
||||
/// release: 1.034 sec
|
||||
/// debug:
|
||||
func testPerformanceHash() {
|
||||
measure {
|
||||
for _ in 0..<maxIterations {
|
||||
_ = StringHashing.singer_djb2(String(describing: Color.self))
|
||||
_ = StringHashing.singer_djb2(String(describing: EmptyComponent.self))
|
||||
_ = StringHashing.singer_djb2(String(describing: Name.self))
|
||||
_ = StringHashing.singer_djb2(String(describing: Party.self))
|
||||
_ = StringHashing.singer_djb2(String(describing: Position.self))
|
||||
_ = StringHashing.singer_djb2(String(describing: SingleGameState.self))
|
||||
_ = StringHashing.singer_djb2(String(describing: Velocity.self))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// release: 1.034 sec
|
||||
/// debug: 1.287 sec
|
||||
func testPerformanceStringDescribing() {
|
||||
measure {
|
||||
for _ in 0..<maxIterations {
|
||||
|
|
@ -40,7 +59,8 @@ final class TypeIdentifierPerformanceTests: XCTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
// 1.587 sec
|
||||
/// release: 1.187 sec
|
||||
/// debug: 1.498 sec
|
||||
func testPerformanceStringReflecting() {
|
||||
measure {
|
||||
for _ in 0..<maxIterations {
|
||||
|
|
@ -55,7 +75,8 @@ final class TypeIdentifierPerformanceTests: XCTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
// 2.817 sec
|
||||
/// release: 2.102 sec
|
||||
/// debug: 2.647 sec
|
||||
func testPerformanceMirrorReflectingDescription() {
|
||||
measure {
|
||||
for _ in 0..<maxIterations {
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@ class TypedFamilyPerformanceTests: XCTestCase {
|
|||
super.tearDown()
|
||||
}
|
||||
|
||||
/// release: 0.011 sec
|
||||
/// debug: 0.017 sec
|
||||
func testMeasureTraitMatching() {
|
||||
let a = nexus.createEntity()
|
||||
a.assign(Position(x: 1, y: 2))
|
||||
|
|
@ -48,6 +50,8 @@ class TypedFamilyPerformanceTests: XCTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
/// release: 0.001 sec
|
||||
/// debug: 0.008 sec
|
||||
func testPerformanceTypedFamilyEntities() {
|
||||
let family = nexus.family(requires: Position.self, excludesAll: Party.self)
|
||||
|
||||
|
|
@ -71,6 +75,7 @@ class TypedFamilyPerformanceTests: XCTestCase {
|
|||
XCTAssertEqual(loopCount, family.count * 10)
|
||||
}
|
||||
|
||||
/// debug: 0.004 sec
|
||||
func testPerformanceArray() {
|
||||
let positions = [Position](repeating: Position(x: Int.random(in: 0...10), y: Int.random(in: 0...10)), count: numEntities)
|
||||
|
||||
|
|
@ -87,6 +92,8 @@ class TypedFamilyPerformanceTests: XCTestCase {
|
|||
XCTAssertEqual(loopCount, numEntities * 10)
|
||||
}
|
||||
|
||||
/// release: 0.003 sec
|
||||
/// debug: 0.010 sec
|
||||
func testPerformanceTypedFamilyOneComponent() {
|
||||
let family = nexus.family(requires: Position.self, excludesAll: Party.self)
|
||||
|
||||
|
|
@ -109,6 +116,8 @@ class TypedFamilyPerformanceTests: XCTestCase {
|
|||
XCTAssertEqual(loopCount, family.count * 10)
|
||||
}
|
||||
|
||||
/// release: 0.004 sec
|
||||
/// debug: 0.016 sec
|
||||
func testPerformanceTypedFamilyEntityOneComponent() {
|
||||
let family = nexus.family(requires: Position.self, excludesAll: Party.self)
|
||||
|
||||
|
|
@ -133,6 +142,8 @@ class TypedFamilyPerformanceTests: XCTestCase {
|
|||
XCTAssertEqual(loopCount, family.count * 10)
|
||||
}
|
||||
|
||||
/// release: 0.005 sec
|
||||
/// debug: 0.016 sec
|
||||
func testPerformanceTypedFamilyTwoComponents() {
|
||||
let family = nexus.family(requiresAll: Position.self, Velocity.self, excludesAll: Party.self)
|
||||
|
||||
|
|
@ -156,6 +167,7 @@ class TypedFamilyPerformanceTests: XCTestCase {
|
|||
XCTAssertEqual(loopCount, family.count * 10)
|
||||
}
|
||||
|
||||
/// release: 0.006 sec
|
||||
func testPerformanceTypedFamilyEntityTwoComponents() {
|
||||
let family = nexus.family(requiresAll: Position.self, Velocity.self, excludesAll: Party.self)
|
||||
|
||||
|
|
@ -181,6 +193,7 @@ class TypedFamilyPerformanceTests: XCTestCase {
|
|||
XCTAssertEqual(loopCount, family.count * 10)
|
||||
}
|
||||
|
||||
/// release: 0.007 sec
|
||||
func testPerformanceTypedFamilyThreeComponents() {
|
||||
let family = nexus.family(requiresAll: Position.self, Velocity.self, Name.self, excludesAll: Party.self)
|
||||
|
||||
|
|
@ -205,6 +218,7 @@ class TypedFamilyPerformanceTests: XCTestCase {
|
|||
XCTAssertEqual(loopCount, family.count * 10)
|
||||
}
|
||||
|
||||
/// release: 0.008 sec
|
||||
func testPerformanceTypedFamilyEntityThreeComponents() {
|
||||
let family = nexus.family(requiresAll: Position.self, Velocity.self, Name.self, excludesAll: Party.self)
|
||||
|
||||
|
|
@ -231,6 +245,7 @@ class TypedFamilyPerformanceTests: XCTestCase {
|
|||
XCTAssertEqual(loopCount, family.count * 10)
|
||||
}
|
||||
|
||||
/// release: 0.009 sec
|
||||
func testPerformanceTypedFamilyFourComponents() {
|
||||
let family = nexus.family(requiresAll: Position.self, Velocity.self, Name.self, Color.self, excludesAll: Party.self)
|
||||
|
||||
|
|
@ -256,6 +271,7 @@ class TypedFamilyPerformanceTests: XCTestCase {
|
|||
XCTAssertEqual(loopCount, family.count * 10)
|
||||
}
|
||||
|
||||
/// release: 0.010 sec
|
||||
func testPerformanceTypedFamilyEntityFourComponents() {
|
||||
let family = nexus.family(requiresAll: Position.self, Velocity.self, Name.self, Color.self, excludesAll: Party.self)
|
||||
|
||||
|
|
@ -283,6 +299,7 @@ class TypedFamilyPerformanceTests: XCTestCase {
|
|||
XCTAssertEqual(loopCount, family.count * 10)
|
||||
}
|
||||
|
||||
/// release: 0.012 sec
|
||||
func testPerformanceTypedFamilyFiveComponents() {
|
||||
let family = nexus.family(requiresAll: Position.self, Velocity.self, Name.self, Color.self, EmptyComponent.self, excludesAll: Party.self)
|
||||
|
||||
|
|
@ -308,6 +325,7 @@ class TypedFamilyPerformanceTests: XCTestCase {
|
|||
XCTAssertEqual(loopCount, family.count * 10)
|
||||
}
|
||||
|
||||
/// release: 0.012 sec
|
||||
func testPerformanceTypedFamilyEntityFiveComponents() {
|
||||
let family = nexus.family(requiresAll: Position.self, Velocity.self, Name.self, Color.self, EmptyComponent.self, excludesAll: Party.self)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue