Skip to content

Commit f72c187

Browse files
authored
[Android benchmark] introduce warm up iterations
Differential Revision: D70017241 Pull Request resolved: #8626
1 parent 54dccc9 commit f72c187

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

extension/benchmark/android/benchmark/app/src/main/java/org/pytorch/minibench/BenchmarkActivity.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ protected void onCreate(Bundle savedInstanceState) {
4444
.get();
4545

4646
int numIter = intent.getIntExtra("num_iter", 50);
47+
int numWarmupIter = intent.getIntExtra("num_warm_up_iter", 5);
4748

4849
// TODO: Format the string with a parsable format
4950
Stats stats = new Stats();
@@ -58,6 +59,10 @@ protected Void doInBackground(Void... voids) {
5859
stats.errorCode = module.loadMethod("forward");
5960
stats.loadEnd = System.nanoTime();
6061

62+
for (int i = 0; i < numWarmupIter; i++) {
63+
module.forward();
64+
}
65+
6166
for (int i = 0; i < numIter; i++) {
6267
long start = System.nanoTime();
6368
module.forward();

0 commit comments

Comments
 (0)