Print duration
This commit is contained in:
parent
50dd18ea43
commit
e34db0fa02
1 changed files with 9 additions and 0 deletions
|
@ -1,3 +1,5 @@
|
|||
import Foundation
|
||||
|
||||
protocol Puzzle {
|
||||
mutating func run()
|
||||
init()
|
||||
|
@ -5,8 +7,15 @@ protocol Puzzle {
|
|||
|
||||
extension Puzzle {
|
||||
static func main() {
|
||||
let start = Date()
|
||||
var instance = Self()
|
||||
instance.run()
|
||||
let duration = Date().timeIntervalSince(start)
|
||||
if duration > 1 {
|
||||
print(String(format: "Took %.2f s", duration))
|
||||
} else {
|
||||
print(String(format: "Took %.2f ms", 1000 * duration))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue