Last active
January 1, 2016 12:18
-
-
Save takke/8143276 to your computer and use it in GitHub Desktop.
benchmark
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
// kick parallel (for benchmark) | |
class Box { | |
long total = 0; | |
int child = 0; | |
} | |
final Box box = new Box(); | |
final int childCount = 10; | |
for (int i=0; i<childCount; i++) { | |
box.child ++; | |
new MyAsyncTask<Void, Void, Void>() { | |
@Override | |
protected Void doInBackground(Void... params) { | |
final long startTick = System.currentTimeMillis(); | |
try { | |
twitter.showStatus(mInReplyToStatusId); | |
} catch (TwitterException e) { | |
MyLog.e("twitter.showStatus, error"); | |
} | |
box.total += System.currentTimeMillis() - startTick; | |
MyLog.dWithElapsedTime("twitter.showStatus, [{elapsed}ms]", startTick); | |
box.child --; | |
if (box.child == 0) { | |
MyLog.d("twitter.showStatus, average: [" + box.total/childCount + "ms]"); | |
} | |
return null; | |
} | |
}.parallelExecute(); | |
SystemClock.sleep(100); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment