Create a gist now

Instantly share code, notes, and snippets.

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