Created
January 5, 2014 14:47
-
-
Save rsaunders100/8269049 to your computer and use it in GitHub Desktop.
Timed Scope Smoothed
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
CFAbsoluteTime startTimeStamp = CFAbsoluteTimeGetCurrent(); | |
<#code to time#> | |
static NSTimeInterval smoothedTimeTaken = 0.0; | |
NSTimeInterval timeTaken = (CFAbsoluteTimeGetCurrent() - startTimeStamp); | |
if (smoothedTimeTaken == 0) smoothedTimeTaken = timeTaken; | |
else smoothedTimeTaken = smoothedTimeTaken * 0.9 + timeTaken * 0.1; | |
NSLog(@"Took %0.1f ms (smoothed) to <#name of task#>", smoothedTimeTaken * 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment