diff options
author | Mikkel Krautz <mikkel@krautz.dk> | 2010-06-24 22:24:33 +0400 |
---|---|---|
committer | Mikkel Krautz <mikkel@krautz.dk> | 2010-06-24 22:24:33 +0400 |
commit | b696aeb6105b64d262847401a126096363bdcd85 (patch) | |
tree | a37fe4a8ccd6f7db768a13fe02064c6fc6089c51 | |
parent | 2d4c2ab9c2694c2cb09b85f45891fb18562f0c72 (diff) |
Record time-since-launch in diagnostics reports.
-rw-r--r-- | Source/Classes/AppDelegate.h | 2 | ||||
-rw-r--r-- | Source/Classes/AppDelegate.m | 9 | ||||
-rw-r--r-- | Source/Classes/DiagnosticsViewController.h | 1 | ||||
-rw-r--r-- | Source/Classes/DiagnosticsViewController.m | 23 |
4 files changed, 28 insertions, 7 deletions
diff --git a/Source/Classes/AppDelegate.h b/Source/Classes/AppDelegate.h index f8a2e5d..c839624 100644 --- a/Source/Classes/AppDelegate.h +++ b/Source/Classes/AppDelegate.h @@ -31,6 +31,7 @@ @interface AppDelegate : NSObject <UIApplicationDelegate> { UIWindow *window; UINavigationController *navigationController; + NSDate *_launchDate; } @property (nonatomic, retain) IBOutlet UIWindow *window; @@ -40,6 +41,7 @@ - (void) applicationWillTerminate:(UIApplication *)application; - (void) reloadPreferences; +- (NSTimeInterval) timeIntervalSinceLaunch; @end diff --git a/Source/Classes/AppDelegate.m b/Source/Classes/AppDelegate.m index 4f383e3..e60c5fd 100644 --- a/Source/Classes/AppDelegate.m +++ b/Source/Classes/AppDelegate.m @@ -33,7 +33,6 @@ #import "WelcomeScreenPhone.h" #import "WelcomeScreenPad.h" #import "Database.h" -#import "Certificate.h" #import <MumbleKit/MKAudio.h> @@ -47,6 +46,8 @@ @synthesize navigationController; - (void) applicationDidFinishLaunching:(UIApplication *)application { + _launchDate = [[NSDate alloc] init]; + [window addSubview:[navigationController view]]; [window makeKeyAndVisible]; @@ -80,6 +81,7 @@ } - (void) dealloc { + [_launchDate release]; [navigationController release]; [window release]; [super dealloc]; @@ -112,4 +114,9 @@ [self setupAudio]; } +// Time since we launched +- (NSTimeInterval) timeIntervalSinceLaunch { + return [[NSDate date] timeIntervalSinceDate:_launchDate]; +} + @end diff --git a/Source/Classes/DiagnosticsViewController.h b/Source/Classes/DiagnosticsViewController.h index 3da3370..65d1d34 100644 --- a/Source/Classes/DiagnosticsViewController.h +++ b/Source/Classes/DiagnosticsViewController.h @@ -38,6 +38,7 @@ UITableViewCell *_versionCell; UITableViewCell *_gitRevCell; UITableViewCell *_buildDateCell; + UITableViewCell *_sinceLaunchCell; UITableViewCell *_preprocessorCell; diff --git a/Source/Classes/DiagnosticsViewController.m b/Source/Classes/DiagnosticsViewController.m index 4795e02..8202eaa 100644 --- a/Source/Classes/DiagnosticsViewController.m +++ b/Source/Classes/DiagnosticsViewController.m @@ -33,6 +33,7 @@ #include <sys/types.h> #include <sys/sysctl.h> +#import "AppDelegate.h" #import "DiagnosticsViewController.h" @interface DiagnosticsViewController (Private) @@ -80,7 +81,7 @@ [[_udidCell detailTextLabel] setText:[device uniqueIdentifier]]; [[_udidCell detailTextLabel] setAdjustsFontSizeToFitWidth:YES]; - // Build + // Application _versionCell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"DiagnosticsCell"]; [_versionCell setSelectionStyle:UITableViewCellSelectionStyleNone]; [[_versionCell textLabel] setText:@"Version"]; @@ -97,6 +98,12 @@ [[_buildDateCell detailTextLabel] setText:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"MumbleBuildDate"]]; [[_buildDateCell detailTextLabel] setAdjustsFontSizeToFitWidth:YES]; + _sinceLaunchCell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"DiagnosticsCell"]; + [_sinceLaunchCell setSelectionStyle:UITableViewCellSelectionStyleNone]; + [[_sinceLaunchCell textLabel] setText:@"Time Since Launch"]; + [[_sinceLaunchCell detailTextLabel] setText:[NSString stringWithFormat:@"%.2f", [(AppDelegate *)[[UIApplication sharedApplication] delegate] timeIntervalSinceLaunch]]]; + [[_sinceLaunchCell detailTextLabel] setAdjustsFontSizeToFitWidth:YES]; + // Audio _preprocessorCell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"DiagnosticsCell"]; [_preprocessorCell setSelectionStyle:UITableViewCellSelectionStyleNone]; @@ -144,8 +151,8 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if (section == 0) // System return 3; - if (section == 1) // Build - return 3; + if (section == 1) // Application + return 4; if (section == 2) // Audio return 1; return 0; @@ -155,7 +162,7 @@ if (section == 0) return @"System"; if (section == 1) - return @"Build"; + return @"Application"; if (section == 2) return @"Audio"; return @"Default"; @@ -170,13 +177,15 @@ } else if ([indexPath row] == 2) { // UDID return _udidCell; } - } else if ([indexPath section] == 1) { // Build + } else if ([indexPath section] == 1) { // Application if ([indexPath row] == 0) { // Version return _versionCell; } else if ([indexPath row] == 1) { // Git Revision return _gitRevCell; } else if ([indexPath row] == 2) { // Build Date return _buildDateCell; + } else if ([indexPath row] == 3) { // Time since launch + return _sinceLaunchCell; } } else if ([indexPath section] == 2) { // Audio if ([indexPath row] == 0) { // Preprocessor @@ -233,6 +242,7 @@ [audio getBenchmarkData:&data]; [[_preprocessorCell detailTextLabel] setText:[NSString stringWithFormat:@"%li µs", data.avgPreprocessorRuntime]]; + [[_sinceLaunchCell detailTextLabel] setText:[NSString stringWithFormat:@"%.2f", [(AppDelegate *)[[UIApplication sharedApplication] delegate] timeIntervalSinceLaunch]]]; } - (NSData *) formEncodedDictionary:(NSDictionary *)dict boundary:(NSString *)boundary { @@ -260,10 +270,11 @@ [dict setObject:[self deviceString] forKey:@"device"]; [dict setObject:[NSString stringWithFormat:@"%@ %@", [device systemName], [device systemVersion]] forKey:@"operating-system"]; [dict setObject:[device uniqueIdentifier] forKey:@"udid"]; - // Build + // Application [dict setObject:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"] forKey:@"version"]; [dict setObject:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"MumbleGitRevision"] forKey:@"git-revision"]; [dict setObject:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"MumbleBuildDate"] forKey:@"build-date"]; + [dict setObject:[NSString stringWithFormat:@"%.2f", [(AppDelegate *)[[UIApplication sharedApplication] delegate] timeIntervalSinceLaunch]] forKey:@"time-since-launch"]; // Audio [dict setObject:[NSString stringWithFormat:@"%li", bench.avgPreprocessorRuntime] forKey:@"preprocessor-avg-runtime"]; |