Skip to content

Instantly share code, notes, and snippets.

@rsaunders100
Created January 5, 2014 14:47
Show Gist options
  • Save rsaunders100/8269049 to your computer and use it in GitHub Desktop.
Save rsaunders100/8269049 to your computer and use it in GitHub Desktop.
Timed Scope Smoothed
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