File tree Expand file tree Collapse file tree 1 file changed +0
-17
lines changed Expand file tree Collapse file tree 1 file changed +0
-17
lines changed Original file line number Diff line number Diff line change 9
9
import Foundation
10
10
11
11
struct Utils {
12
- /// Time a block in ms
13
- static func time< T> ( label: String , _ block: ( ) -> T ) -> T {
14
- let startTime = CFAbsoluteTimeGetCurrent ( )
15
- let result = block ( )
16
- let diff = ( CFAbsoluteTimeGetCurrent ( ) - startTime) * 1_000
17
- print ( " [ \( label) ] \( diff) ms " )
18
- return result
19
- }
20
-
21
- /// Time a block in seconds and return (output, time)
22
- static func time< T> ( _ block: ( ) -> T ) -> ( T , Double ) {
23
- let startTime = CFAbsoluteTimeGetCurrent ( )
24
- let result = block ( )
25
- let diff = CFAbsoluteTimeGetCurrent ( ) - startTime
26
- return ( result, diff)
27
- }
28
-
29
12
/// Return unix timestamp in ms
30
13
static func dateNow( ) -> Int64 {
31
14
// Use `Int` when we don't support 32-bits devices/OSes anymore.
You can’t perform that action at this time.
0 commit comments