From 8fcf8f468e350a29af0436f1f47777a2a0c825f5 Mon Sep 17 00:00:00 2001 From: David Sehr Date: Wed, 23 Oct 2019 15:05:03 -0700 Subject: [PATCH] Add initialization check benchmark Add a benchmark to test the cost of initialization checks. The application run with JIT versus AOT shows the cost of initialization checks of other classes. Bug: none Test: run the test, compile, run the test again Change-Id: Ic15d872e2284084e003056849453150fb533ca81 --- startop/apps/test/Android.bp | 2 + startop/apps/test/AndroidManifest.xml | 12 ++ .../InitCheckOverheadBenchmarkActivity.java | 30 ++++ .../test/src/InitCheckOverheadBenchmarks.java | 134 ++++++++++++++++++ 4 files changed, 178 insertions(+) create mode 100644 startop/apps/test/src/InitCheckOverheadBenchmarkActivity.java create mode 100644 startop/apps/test/src/InitCheckOverheadBenchmarks.java diff --git a/startop/apps/test/Android.bp b/startop/apps/test/Android.bp index 5de7fd2fb0a04..3f20273a8d61a 100644 --- a/startop/apps/test/Android.bp +++ b/startop/apps/test/Android.bp @@ -22,6 +22,8 @@ android_app { "src/CPUIntensiveBenchmarks.java", "src/EmptyActivity.java", "src/FrameLayoutInflationActivity.java", + "src/InitCheckOverheadBenchmarkActivity.java", + "src/InitCheckOverheadBenchmarks.java", "src/LayoutInflationActivity.java", "src/NonInteractiveSystemServerBenchmarkActivity.java", "src/SystemServerBenchmarkActivity.java", diff --git a/startop/apps/test/AndroidManifest.xml b/startop/apps/test/AndroidManifest.xml index b08072e00584c..235aa0d25e860 100644 --- a/startop/apps/test/AndroidManifest.xml +++ b/startop/apps/test/AndroidManifest.xml @@ -72,6 +72,18 @@ + + + + + + + + + { + doGC(); + }); + + benchmarks.addBenchmark("InitCheckFor (local)", () -> { + localStaticFor(10000000); + }); + + benchmarks.addBenchmark("InitCheckFor (non-local)", () -> { + nonLocalStaticFor(10000000); + }); + + benchmarks.addBenchmark("InitCheckForTwo (local)", () -> { + localStaticForTwo(10000000); + }); + + benchmarks.addBenchmark("InitCheckForTwo (non-local)", () -> { + nonLocalStaticForTwo(10000000); + }); + + benchmarks.addBenchmark("InitCheckDoWhile (local)", () -> { + localStaticDoWhile(10000000); + }); + + benchmarks.addBenchmark("InitCheckDoWhile (non-local)", () -> { + nonLocalStaticDoWhile(10000000); + }); + } +}