Avatar
ああ、Clockは5.7からか
1:57 AM
@swift-5.6.3 -O @_optimize(none) func blackhole<T>(_: T) {} struct Element { var value1: Int64 var value2: Int64 var tails: [Int64] } func modifyElement(items: [Element]) { var items = items var item = items[0] item.value1 = 42 item.tails[0] = 50 items[0] = item blackhole(items) } import Foundation let start = Date() for _ in 0..<1000000 { let baseItems = [ Element(value1: 1, value2: 2, tails: Array(repeating: 24, count: 3000)), ] modifyElement(items: baseItems) } let elapsed = Date().timeIntervalSince(start) print("took \(elapsed)") (edited)