Skip to content

Instantly share code, notes, and snippets.

@astojilj
Created May 20, 2019 06:01
Show Gist options
  • Save astojilj/29bd5a5c5dc0b2d9f29ecb660da07fbf to your computer and use it in GitHub Desktop.
Save astojilj/29bd5a5c5dc0b2d9f29ecb660da07fbf to your computer and use it in GitHub Desktop.
measure relinking patch and measured results
diff --git a/src/mbgl/gl/program.hpp b/src/mbgl/gl/program.hpp
index 3757c442d..9d4eb7c24 100644
--- a/src/mbgl/gl/program.hpp
+++ b/src/mbgl/gl/program.hpp
@@ -23,6 +23,8 @@
#include <string>
+#import <QuartzCore/QuartzCore.h>
+
namespace mbgl {
namespace gl {
@@ -52,8 +54,10 @@ public:
context.createShader(ShaderType::Fragment, fragmentSource))),
attributeLocations(context, program) {
// Re-link program after manually binding only active attributes in Attributes::queryLocations
+ auto t = CACurrentMediaTime();
context.linkProgram(program);
-
+ t = (CACurrentMediaTime() - t) * 1000;
+ printf("Relinking took %f ms\n", t);
// We have to re-initialize the uniforms state from the bindings as the uniform locations
// get shifted on some implementations
uniformStates.queryLocations(program);
Measured, just the relinking, on release build on iPhone SE (A9, same as iPhone 6S)
- 1st run after reboot or installation
Total 37.14ms, average per program:1.86ms
- reopening
Total: 2.47ms, average per program: 0.12ms
reopen | 1st run on reboot/installation:
0.089083 1.069083
0.078750 0.507042
0.098250 3.149375
0.100167 3.043375
0.224167 3.108500
0.085375 2.599583
0.132875 0.704458
0.133417 2.531875
0.121333 1.037083
0.118708 1.114417
0.114333 4.230750
0.120625 1.304708
0.105833 2.585708
0.115125 1.305125
0.124333 1.053333
0.113792 3.133375
0.152833 0.894333
0.132708 1.108625
0.155708 1.449792
0.149292 1.214833
1.409750
3.223042
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment