Created
February 17, 2017 13:03
-
-
Save LaruYan/26dc7792a9e31e89a6e583941f46ed02 to your computer and use it in GitHub Desktop.
I tried some of screen orientation checks for android and looped that 100,000 times.. The other does same but 240 times slower!
This file contains 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
<?xml version="1.0" encoding="utf-8"?> | |
<resources> | |
<bool name="is_landscape">true</bool> | |
</resources> |
This file contains 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
<?xml version="1.0" encoding="utf-8"?> | |
<resources> | |
<bool name="is_landscape">false</bool> | |
</resources> |
This file contains 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
long startTime = System.currentTimeMillis(); | |
long sum = 0; | |
for(int i = 1; i <= 1000000 ; i ++) { | |
// D/LANDTEST: sum: 500000500000 / time: 32 | |
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { | |
sum += i; | |
} | |
// D/LANDTEST: sum: 500000500000 / time: 7743 | |
if (getResources().getBoolean(R.bool.is_landscape)) { | |
sum += i; | |
} | |
} | |
Log.d("LANDTEST", "sum: " + sum + " / time: " + (System.currentTimeMillis() - startTime)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment