Skip to content

Instantly share code, notes, and snippets.

@takke
Last active January 1, 2016 12:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takke/8143276 to your computer and use it in GitHub Desktop.
Save takke/8143276 to your computer and use it in GitHub Desktop.
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