mirror of
https://github.com/apple/swift-collections
synced 2026-11-26 04:47:48 +00:00
[Collections] Allow determining if internal checking is enabled
In the benchmark target, complain loudly if consistency checks are enabled.
This commit is contained in:
1 parent
53895c6537
commit
12e3867ccb
6 files changed
+53
-4
No files matched your search
@@ -11,6 +11,18 @@
|
||||
|
||||
import CollectionsBenchmark
|
||||
import Benchmarks
|
||||
import DequeModule
|
||||
|
||||
if Deque<Int>._isConsistencyCheckingEnabled {
|
||||
complain("""
|
||||
*** INTERNAL CONSISTENCY CHECKING IS ENABLED ***
|
||||
|
||||
Performance guarantees aren't valid in this configuration,
|
||||
and benchmarking data will be largely useless. Proceed at
|
||||
your own risk.
|
||||
|
||||
""")
|
||||
}
|
||||
|
||||
var benchmark = Benchmark(title: "Collection Benchmarks")
|
||||
benchmark.registerCustomGenerators()
|
||||
|
||||
@@ -9,10 +9,16 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
import _CollectionsUtilities
|
||||
|
||||
// This file contains exported but non-public entry points to support clear box
|
||||
// testing.
|
||||
|
||||
extension Deque {
|
||||
public static var _isConsistencyCheckingEnabled: Bool {
|
||||
_isCollectionsInternalCheckingEnabled
|
||||
}
|
||||
|
||||
/// The maximum number of elements this deque is currently able to store
|
||||
/// without reallocating its storage buffer.
|
||||
///
|
||||
|
||||
@@ -9,12 +9,18 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
import _CollectionsUtilities
|
||||
|
||||
extension OrderedSet._UnstableInternals {
|
||||
@_spi(Testing) public var capacity: Int { base._capacity }
|
||||
@_spi(Testing) public var minimumCapacity: Int { base._minimumCapacity }
|
||||
@_spi(Testing) public var scale: Int { base._scale }
|
||||
@_spi(Testing) public var reservedScale: Int { base._reservedScale }
|
||||
@_spi(Testing) public var bias: Int { base._bias }
|
||||
|
||||
public static var isConsistencyCheckingEnabled: Bool {
|
||||
_isCollectionsInternalCheckingEnabled
|
||||
}
|
||||
}
|
||||
|
||||
extension OrderedSet {
|
||||
|
||||
+4
-2
@@ -12,12 +12,14 @@
|
||||
import _CollectionsUtilities
|
||||
|
||||
extension PersistentDictionary {
|
||||
public static var _isConsistencyCheckingEnabled: Bool {
|
||||
_isCollectionsInternalCheckingEnabled
|
||||
}
|
||||
|
||||
public func _dump(iterationOrder: Bool = false) {
|
||||
_root.dump(iterationOrder: iterationOrder)
|
||||
}
|
||||
}
|
||||
|
||||
extension PersistentDictionary {
|
||||
public static var _maxDepth: Int {
|
||||
_Level.limit
|
||||
}
|
||||
|
||||
@@ -9,10 +9,14 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
import Swift
|
||||
import _CollectionsUtilities
|
||||
|
||||
extension Heap {
|
||||
#if COLLECTIONS_INTERNAL_CHECKS
|
||||
public static var _isConsistencyCheckingEnabled: Bool {
|
||||
_isCollectionsInternalCheckingEnabled
|
||||
}
|
||||
|
||||
#if COLLECTIONS_INTERNAL_CHECKSx
|
||||
/// Visits each item in the heap in depth-first order, verifying that the
|
||||
/// contents satisfy the min-max heap property.
|
||||
@inlinable
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This source file is part of the Swift Collections open source project
|
||||
//
|
||||
// Copyright (c) 2022 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
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
@inlinable @inline(__always)
|
||||
public var _isCollectionsInternalCheckingEnabled: Bool {
|
||||
#if COLLECTIONS_INTERNAL_CHECKS
|
||||
return true
|
||||
#else
|
||||
return false
|
||||
#endif
|
||||
}
|
||||
Reference in new issue
Block a user