Skip to content

appcorn/ACBenchmarkHelper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ACBenchmarkHelper ========================= This class benchmarks the time consumed by parts of your code in Cocoa / Cocoa Touch. By calling the mark-method in your code, you can easily measure what parts of you code takes time to run. Since the majority of all the calculations aren't made until the report-method is called, this class aims to have a minimal effect on performance when included in you project. Usage ------------------------- To benchmark your application, simply use the mark and report methods - (void)applicationDidFinishLaunching:(UIApplication *)application { // --- Benchmark --- [ACBenchmarkHelper mark:@"Prepare database"]; [self prepareDatabase]; // --- Benchmark --- [ACBenchmarkHelper mark:@"Creating controller"]; ACContactsController *contactsController = [[ACContactsController alloc] initWithStyle:UITableViewStylePlain]; UINavigationController *contactsNavigationController = [[UINavigationController alloc] initWithRootViewController:contactsController]; [contactsController release]; // --- Benchmark --- [ACBenchmarkHelper mark:@"Adding subview and makeKeyAndVisible"]; [window addSubview:contactsNavigationController.view]; [window makeKeyAndVisible]; // --- Benchmark --- [ACBenchmarkHelper mark:@"starts syncing or login"]; if (loggedIn) { [self startSync]; } else { [self login]; } // --- Benchmark --- [ACBenchmarkHelper report]; } The benchmark helper will measure the time passing between the marks made. The first mark (named "Prepare database") will measure the row containing [self prepareDatabase]. The last mark will be measured from where the mark is made to the report-call. A fancy table will be printed to the console when the report method is run. The example above would result in something like this: ┌────────────────────────────────────────────────────────────┐ │Benchmark Report 4 marks│ ├────────────────────────────────────────┬─────────┬─────────┤ │Title │Time (s) │Total (s)│ ├────────────────────────────────────────┼─────────┼─────────┤ |prepareDatabase | 0.0037 | 0.0037 | |creating controllers | 2.6471 | 2.6508 | ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒... |adding subview and makeKeyAndVisible | 0.0412 | 2.6919 | ▒▒▒▒ |starts syncing or login | 0.0164 | 2.7083 | ▒ └────────────────────────────────────────┴─────────┴─────────┘ You can also make a regular instance of the benchmark helper and use the methods in a non static manner. Example: ACBenchmarkHelper *benchmark = [[ACBenchmarkHelper alloc] init]; [benchmark mark:@"Test"]; // Do something time consuming... [benchmark report]; [benchmark release]; License ------------------------- ACBenchmarkHelper is released under the MIT-license (see the LICENSE file)

About

A class to benchmark the time consumed by parts of your code in Cocoa / Cocoa Touch

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published