summaryrefslogtreecommitdiff
path: root/platform/ios/src/MGLMapView.mm
diff options
context:
space:
mode:
Diffstat (limited to 'platform/ios/src/MGLMapView.mm')
-rw-r--r--platform/ios/src/MGLMapView.mm36
1 files changed, 36 insertions, 0 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index f772432eb7..a0f0514e13 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -240,6 +240,12 @@ public:
@property (nonatomic) MGLUserLocation *userLocation;
@property (nonatomic) NSMutableDictionary<NSString *, NSMutableArray<MGLAnnotationView *> *> *annotationViewReuseQueueByIdentifier;
+/// Experimental rendering performance measurement.
+@property (nonatomic) BOOL experimental_enableFrameRateMeasurement;
+@property (nonatomic) CGFloat averageFrameRate;
+@property (nonatomic) CFTimeInterval frameTime;
+@property (nonatomic) CFTimeInterval averageFrameTime;
+
@end
@implementation MGLMapView
@@ -296,6 +302,11 @@ public:
BOOL _accessibilityValueAnnouncementIsPending;
MGLReachability *_reachability;
+
+ /// Experimental rendering performance measurement.
+ CFTimeInterval _frameCounterStartTime;
+ NSInteger _frameCount;
+ CFTimeInterval _frameDurations;
}
#pragma mark - Setup & Teardown -
@@ -1104,6 +1115,31 @@ public:
[self.glView display];
}
+
+ if (self.experimental_enableFrameRateMeasurement)
+ {
+ CFTimeInterval now = CACurrentMediaTime();
+
+ self.frameTime = now - _displayLink.timestamp;
+ _frameDurations += self.frameTime;
+
+ _frameCount++;
+
+ CFTimeInterval elapsed = now - _frameCounterStartTime;
+
+ if (elapsed >= 1.0) {
+ self.averageFrameRate = _frameCount / elapsed;
+ self.averageFrameTime = (_frameDurations / _frameCount) * 1000;
+
+ _frameCount = 0;
+ _frameDurations = 0;
+ _frameCounterStartTime = now;
+ }
+
+ //CGFloat effectiveFPS = fminf(roundf(1.0 / frameTime), UIScreen.mainScreen.maximumFramesPerSecond);
+
+ //NSLog(@"%.4f frame time (%.4f), %.0f effective FPS (%ld max)", frameTime, _displayLink.duration, effectiveFPS, (long)UIScreen.mainScreen.maximumFramesPerSecond);
+ }
}
- (void)setNeedsGLDisplay