Skip to content

Instantly share code, notes, and snippets.

View andersio's full-sized avatar

Anders Ha andersio

View GitHub Profile

Keybase proof

I hereby claim:

  • I am andersio on github.
  • I am andersio (https://keybase.io/andersio) on keybase.
  • I have a public key ASDa2yXgwned0xqa0bhwhDA8HmeTa-CrvUC5BuZ4na-TFgo

To claim this, I am signing this object:

protocol P {
func foo()
func bar()
}
extension P {
func foo() { print("foo() from P") }
func bar() { print("bar() from P") }
}
import XCTest
import ReactiveSwift
import Result
private func _measure(times: UInt64 = 2_000_000, label: String = #function, _ action: (() -> UInt64) -> Void) {
var result: UInt64 = 0
var minResult: UInt64 = .max
for i in 0 ..< times {
var start: UInt64!
import XCTest
import ReactiveSwift
import Result
private func _measure(times: UInt64 = 2_000_000, label: String = #function, _ action: (() -> UInt64) -> Void) {
var result: UInt64 = 0
var minResult: UInt64 = .max
for i in 0 ..< times {
var start: UInt64!
import XCTest
private func _measure(times: UInt64 = 2_000_000, label: String = #function, _ action: (() -> UInt64) -> Void) {
var result: UInt64 = 0
var minResult: UInt64 = .max
for i in 0 ..< times {
var start: UInt64!
action {
start = mach_absolute_time()
import XCTest
import ReactiveSwift
import Result
private func _measure(times: UInt64 = 2_000_000, label: String = #function, _ action: (() -> UInt64) -> Void) {
var result: UInt64 = 0
var minResult: UInt64 = .max
for i in 0 ..< times {
var start: UInt64!
class ManuallyFinishingOperation: BlockOperation {
override var isFinished: Bool {
return _isFinished && super.isFinished
}
var _isFinished: Bool = false {
willSet { willChangeValue(forKey: "isFinished") }
didSet { didChangeValue(forKey: "isFinished") }
}
import XCTest
import ReactiveSwift
import Result
private func _measure(times: UInt64 = 2_000_000, label: String = #function, _ action: (() -> UInt64) -> Void) {
var result: UInt64 = 0
var minResult: UInt64 = .max
for i in 0 ..< times {
var start: UInt64!
import XCTest
import ReactiveSwift
import Result
class BagTests: XCTestCase {
func testCopying() {
var _bag = Bag<Int>()
_ = (0 ..< 32_768).map { _bag.insert($0) }
self.measure {
// `Entity` protocol.
protocol Entity: Codeable {
var identifier: UInt { get }
}
protocol EntityIdentifer: Codeable {
var identifier: UInt { get }
}
struct Identifier<E: Entity>: EntityIdentifer {