These guys mention android.os.SystemClock, which works for me:
package com.example.benchmark;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
import java.util.Formatter;
import android.os.SystemClock;
public class BenchmarkActivity extends Activity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
long before = SystemClock.uptimeMillis();
long i, j=0;
for(i=0; i<23456780; i++) j+=i;
long after = SystemClock.uptimeMillis();
long millis = after - before;
Formatter f = new Formatter();
String foo = f.format("%d", millis).toString();
TextView tv = new TextView(this);
tv.setText(foo);
setContentView(tv);
}
}
No comments:
Post a Comment