Feature: Rewrite regionToBBox and getMarkersRegion in cpp#51
Open
IslamRustamov wants to merge 1 commit intoJiriHoffmann:mainfrom
Open
Feature: Rewrite regionToBBox and getMarkersRegion in cpp#51IslamRustamov wants to merge 1 commit intoJiriHoffmann:mainfrom
IslamRustamov wants to merge 1 commit intoJiriHoffmann:mainfrom
Conversation
5f01224 to
8d4f740
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Re #31
What was done
Test environment
MacBook Pro M1
iOS Emulator
IMPORTANT
I did some calculations to check a couple of things:
Does C++ functions return the same results as original JS functions
To prove that C++ and JS functions return the same results I run the next computations:
https://gist.github.com/IslamRustamov/0c177a062b2af0836104f269f6809ca0 - comparison of regionToBBox
https://gist.github.com/IslamRustamov/3081cd26d04fd3de736eded42f37ea1d - comparison of getMarkersRegion
As a result all of these computations - C++ functions were returning the same results as JS functions, which means that C++ rewrite was correct.
Does C++ functions compute results faster than the original JS functions
To evaluate the speed of computation I did the next things:
Sample code looked like this for both functions (regionToBBox and getMarkersRegion):
https://gist.github.com/IslamRustamov/25514243ae992a6c0e2f3946da5a8d73
The results are, sadly, not in favor of C++:

The reason why C++ performs worse than JS is probably because passing big chunks of data between JS and native side is taking a lot of time. While C++ may compute the result faster, passing of data is still going to be the problem. This can be solved by switching to Turbo Module implementation of these functions, what will (with high probability) produce a better result for C++.
Source: https://medium.com/@islamrustamov/obj-c-turbo-module-vs-c-turbo-module-vs-flutter-platform-channel-e610a344ec92
Note: maybe I messed up something and that's why C++ is not performing well, I am not an average C++ enjoyer so please do find problems in my PR if there are any. Otherwise this PR is actually going to make this lib work slower, so it can be closed.