[ios] fix benchmark app

This commit is contained in:
Konstantin Käfer
2016-02-23 11:50:44 +01:00
parent 9557cd8d93
commit 662edea020
3 changed files with 47 additions and 13 deletions

View File

@@ -1,10 +1,27 @@
#import "MBXBenchAppDelegate.h"
#import "MBXBenchViewController.h"
#import <Mapbox/Mapbox.h>
@implementation MBXBenchAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
- (BOOL)application:(UIApplication*)application
didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
NSString* accessToken = [[NSProcessInfo processInfo] environment][@"MAPBOX_ACCESS_TOKEN"];
if (accessToken) {
// Store to preferences so that we can launch the app later on without having to specify
// token.
[[NSUserDefaults standardUserDefaults] setObject:accessToken forKey:@"access_token"];
} else {
// Try to retrieve from preferences, maybe we've stored them there previously and can reuse
// the token.
accessToken = [[NSUserDefaults standardUserDefaults] objectForKey:@"access_token"];
}
if (!accessToken) {
NSLog(@"No access token set. Mapbox vector tiles won't work.");
} else {
[MGLAccountManager setAccessToken:accessToken];
}
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = [MBXBenchViewController new];
[self.window makeKeyAndVisible];

View File

@@ -1,6 +1,6 @@
#import "MBXBenchViewController.h"
#import <mbgl/ios/MGLMapView.h>
#import <Mapbox/Mapbox.h>
#include "locations.hpp"
@@ -44,7 +44,7 @@
{
[super viewDidLoad];
NSURL* url = [[NSURL alloc] initWithString:@"mapbox://styles/mapbox/streets-v8.json"];
NSURL* url = [[NSURL alloc] initWithString:@"mapbox://styles/mapbox/streets-v8"];
self.mapView = [[MGLMapView alloc] initWithFrame:self.view.bounds styleURL:url];
self.mapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.mapView.delegate = self;
@@ -62,7 +62,7 @@
size_t idx = 0;
enum class State { None, WaitingForAssets, WarmingUp, Benchmarking } state = State::None;
int frames = 0;
TimePoint started;
std::chrono::steady_clock::time_point started;
std::vector<std::pair<std::string, double>> result;
static const int warmupDuration = 20; // frames
@@ -102,7 +102,7 @@ static const int benchmarkDuration = 200; // frames
state = State::None;
// Report FPS
const auto duration = Microseconds(Clock::now() - started);
const auto duration = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::steady_clock::now() - started).count() ;
const auto fps = double(frames * 1e6) / duration;
result.emplace_back(mbgl::bench::locations[idx].name, fps);
NSLog(@"- FPS: %.1f", fps);
@@ -123,7 +123,7 @@ static const int benchmarkDuration = 200; // frames
{
frames = 0;
state = State::Benchmarking;
started = Clock::now();
started = std::chrono::steady_clock::now();
NSLog(@"- Benchmarking for %d frames...", benchmarkDuration);
}
[mapView setNeedsGLDisplay];

View File

@@ -16,10 +16,7 @@
],
'dependencies': [
'mbgl.gyp:core',
'mbgl.gyp:platform-<(platform_lib)',
'mbgl.gyp:http-<(http_lib)',
'mbgl.gyp:asset-<(asset_lib)',
'iossdk',
],
'sources': [
@@ -35,27 +32,47 @@
'xcode_settings': {
'SDKROOT': 'iphoneos',
'SUPPORTED_PLATFORMS': 'iphoneos',
'IPHONEOS_DEPLOYMENT_TARGET': '7.0',
'IPHONEOS_DEPLOYMENT_TARGET': '8.0',
'INFOPLIST_FILE': '../platform/ios/benchmark/app-info.plist',
'TARGETED_DEVICE_FAMILY': '1,2',
'COMBINE_HIDPI_IMAGES': 'NO', # don't merge @2x.png images into .tiff files
'COPY_PHASE_STRIP': 'NO',
'CLANG_ENABLE_OBJC_ARC': 'YES',
'CLANG_ENABLE_MODULES': 'YES',
'LD_RUNPATH_SEARCH_PATHS': [
'$(inherited)',
'@executable_path/Frameworks',
],
'OTHER_LDFLAGS': [
'-framework CoreLocation',
],
},
'configurations': {
'Debug': {
'xcode_settings': {
'CODE_SIGN_IDENTITY': 'iPhone Developer',
'COPY_PHASE_STRIP': 'NO',
},
},
'Release': {
'xcode_settings': {
'CODE_SIGN_IDENTITY': 'iPhone Distribution',
'ARCHS': [ "arm64" ],
'ARCHS': [ "armv7", "armv7s", "arm64", "i386", "x86_64" ],
'COPY_PHASE_STRIP': 'YES',
},
},
},
'copies': [
{
'destination': '<(PRODUCT_DIR)/$(FRAMEWORKS_FOLDER_PATH)',
'files': [
'<(PRODUCT_DIR)/Mapbox.framework',
],
'xcode_code_sign': 1,
},
],
}
]
}