diff --git a/GDPerformanceView.podspec b/GDPerformanceView.podspec index 5287eed..75806fa 100755 --- a/GDPerformanceView.podspec +++ b/GDPerformanceView.podspec @@ -1,13 +1,13 @@ Pod::Spec.new do |s| s.name = "GDPerformanceView" - s.version = "1.3.1" + s.version = "1.3.2" s.summary = "Shows FPS, CPU usage, app and iOS versions above the status bar and report FPS and CPU usage via delegate." s.homepage = "https://github.com/dani-gavrilov/GDPerformanceView" s.license = { :type => "MIT", :file => "LICENSE" } s.author = { "Gavrilov Daniil" => "daniilmbox@gmail.com" } s.platform = :ios, "8.0" s.ios.deployment_target = "8.0" - s.source = { :git => "https://github.com/dani-gavrilov/GDPerformanceView.git", :tag => "1.3.1" } + s.source = { :git => "https://github.com/dani-gavrilov/GDPerformanceView.git", :tag => "1.3.2" } s.source_files = "GDPerformanceView/GDPerformanceMonitoring/*" s.frameworks = "UIKit", "Foundation", "QuartzCore" s.requires_arc = true diff --git a/GDPerformanceView/GDPerformanceMonitoring/GDPerformanceMonitor.h b/GDPerformanceView/GDPerformanceMonitoring/GDPerformanceMonitor.h index 9e481e1..f2f4855 100755 --- a/GDPerformanceView/GDPerformanceMonitoring/GDPerformanceMonitor.h +++ b/GDPerformanceView/GDPerformanceMonitoring/GDPerformanceMonitor.h @@ -43,6 +43,11 @@ */ @property (nonatomic, getter=isDeviceVersionHidden) BOOL deviceVersionHidden; +/** + Change it to update the time interval between each report. Default is 1 sec. + Minimum value is 0.5 sec. + */ +@property (nonatomic) NSTimeInterval updateTimeInterval; /** Creates and returns instance of GDPerformanceMonitor, as singleton. diff --git a/GDPerformanceView/GDPerformanceMonitoring/GDPerformanceMonitor.m b/GDPerformanceView/GDPerformanceMonitoring/GDPerformanceMonitor.m index 4a4cd87..9e8e0c1 100755 --- a/GDPerformanceView/GDPerformanceMonitoring/GDPerformanceMonitor.m +++ b/GDPerformanceView/GDPerformanceMonitoring/GDPerformanceMonitor.m @@ -57,6 +57,7 @@ + (instancetype)sharedInstance { - (instancetype)init { self = [super init]; if (self) { + self.updateTimeInterval = 1.0f; [self subscribeToNotifications]; } return self; @@ -175,6 +176,7 @@ - (void)setupPerformanceView { [self.performanceView setAppVersionHidden:self.appVersionHidden]; [self.performanceView setDeviceVersionHidden:self.deviceVersionHidden]; [self.performanceView setPerformanceDelegate:self.delegate]; + [self.performanceView setUpdateTimeInterval:self.updateTimeInterval]; [self checkAndApplyStatusBarAppearanceWithPrefersStatusBarHidden:self.prefersStatusBarHidden preferredStatusBarStyle:self.preferredStatusBarStyle]; if (self.isPerformanceViewPaused) { @@ -225,4 +227,11 @@ - (void)setDeviceVersionHidden:(BOOL)deviceVersionHidden { } } +- (void)setUpdateTimeInterval:(NSTimeInterval)updateTimeInterval { + _updateTimeInterval = updateTimeInterval; + + if (self.performanceView) { + [self.performanceView setUpdateTimeInterval:updateTimeInterval]; + } +} @end diff --git a/GDPerformanceView/GDPerformanceMonitoring/GDPerformanceView.h b/GDPerformanceView/GDPerformanceMonitoring/GDPerformanceView.h index 9b14001..772c835 100755 --- a/GDPerformanceView/GDPerformanceMonitoring/GDPerformanceView.h +++ b/GDPerformanceView/GDPerformanceMonitoring/GDPerformanceView.h @@ -41,6 +41,12 @@ */ @property (nonatomic, getter=isDeviceVersionHidden) BOOL deviceVersionHidden; +/** + Change it to update the time interval between each report. Default is 1 sec. + Minimum value is 0.5 sec. + */ +@property (nonatomic) NSTimeInterval updateTimeInterval; + /** Override this properties to return the desired status bar attributes. diff --git a/GDPerformanceView/GDPerformanceMonitoring/GDPerformanceView.m b/GDPerformanceView/GDPerformanceMonitoring/GDPerformanceView.m index b212598..a5d5d21 100755 --- a/GDPerformanceView/GDPerformanceMonitoring/GDPerformanceView.m +++ b/GDPerformanceView/GDPerformanceMonitoring/GDPerformanceView.m @@ -149,6 +149,7 @@ - (void)setupWindowAndDefaultVariables { self.screenUpdatesCount = 0; self.screenUpdatesBeginTime = 0.0f; self.averageScreenUpdatesTime = 0.017f; + self.updateTimeInterval = 1.0f; GDWindowViewController *rootViewController = [[GDWindowViewController alloc] init]; @@ -193,22 +194,14 @@ - (void)displayLinkAction:(CADisplayLink *)displayLink { CFTimeInterval screenUpdatesTime = self.displayLink.timestamp - self.screenUpdatesBeginTime; - if (screenUpdatesTime >= 1.0) { - CFTimeInterval updatesOverSecond = screenUpdatesTime - 1.0f; - int framesOverSecond = updatesOverSecond / self.averageScreenUpdatesTime; - - self.screenUpdatesCount -= framesOverSecond; - if (self.screenUpdatesCount < 0) { - self.screenUpdatesCount = 0; - } - + if (screenUpdatesTime >= self.updateTimeInterval) { [self takeReadings]; } } } - (void)takeReadings { - int fps = self.screenUpdatesCount; + int fps = self.screenUpdatesCount / (self.displayLink.timestamp - self.screenUpdatesBeginTime); float cpu = [self cpuUsage]; self.screenUpdatesCount = 0;