Last active
February 28, 2018 14:04
-
-
Save jamesonthecrow/a6454c490efbc7fc177fd8d5353c36fe to your computer and use it in GitHub Desktop.
Benchmarking neural networks in Swift.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Debug { | |
struct Timer { | |
let start = DispatchTime.now().uptimeNanoseconds | |
func end() -> Double { | |
let end = DispatchTime.now().uptimeNanoseconds | |
let diff = Double(end — start) / 1_000_000_000 | |
return diff | |
} | |
} | |
} | |
func timePredict(model: MLModel, inputFeatureProvider: MLFeatureProvider) -> Double { | |
let timer = Debug.Timer() | |
_ = try? model.prediction(from: inputFeatureProvider) | |
return timer.end() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment