Skip to content

Instantly share code, notes, and snippets.

@takke takke/gist:8143276
Last active Jan 1, 2016

Embed
What would you like to do?
benchmark
// 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
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.