diff options
author | Eric Holk <eholk@google.com> | 2019-09-09 15:03:37 -0700 |
---|---|---|
committer | Eric Holk <eholk@google.com> | 2019-09-10 09:46:08 -0700 |
commit | 13926c385c8ca606d9acd8a969a73dc29edd7413 (patch) | |
tree | 8b0d21954915a57f5dbcebb28fa2240bec057cd7 | |
parent | aec05a2cdd9e8863f48ecdc0733b0dc2bd414883 (diff) |
Add additional system_server benchmarks
This CL adds benchmarks for the following PackageManager APIs:
* getInstalledApplications
* getInstalledPackages
* getPackageInfo
* getApplicationInfo
* getResourcesForApplication
* getActivityInfo
Bug: 140743821
Change-Id: I467e4264a5e8f5c1c34194c7ad4b4c415387da9e
-rw-r--r-- | startop/apps/test/src/SystemServerBenchmarkActivity.java | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/startop/apps/test/src/SystemServerBenchmarkActivity.java b/startop/apps/test/src/SystemServerBenchmarkActivity.java index 59a30a540d99..c370924c943c 100644 --- a/startop/apps/test/src/SystemServerBenchmarkActivity.java +++ b/startop/apps/test/src/SystemServerBenchmarkActivity.java @@ -17,8 +17,11 @@ package com.android.startop.test; import android.app.Activity; +import android.content.ComponentName; import android.content.Context; +import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; +import android.content.pm.PackageManager.NameNotFoundException; import android.os.AsyncTask; import android.os.Bundle; import android.os.Trace; @@ -108,5 +111,48 @@ public class SystemServerBenchmarkActivity extends Activity { new Benchmark(benchmarkList, "getInstalledApplications", () -> { pm.getInstalledApplications(PackageManager.MATCH_SYSTEM_ONLY); }); + + new Benchmark(benchmarkList, "getInstalledPackages", () -> { + pm.getInstalledPackages(PackageManager.GET_ACTIVITIES); + }); + + new Benchmark(benchmarkList, "getPackageInfo", () -> { + try { + pm.getPackageInfo("com.android.startop.test", 0); + } catch (NameNotFoundException e) { + throw new RuntimeException(e); + } + }); + + new Benchmark(benchmarkList, "getApplicationInfo", () -> { + try { + pm.getApplicationInfo("com.android.startop.test", 0); + } catch (NameNotFoundException e) { + throw new RuntimeException(e); + } + }); + + try { + ApplicationInfo app = pm.getApplicationInfo("com.android.startop.test", 0); + new Benchmark(benchmarkList, "getResourcesForApplication", () -> { + try { + pm.getResourcesForApplication(app); + } catch (NameNotFoundException e) { + throw new RuntimeException(e); + } + }); + } catch (NameNotFoundException e) { + throw new RuntimeException(e); + } + + ComponentName component = new ComponentName(this, this.getClass()); + new Benchmark(benchmarkList, "getActivityInfo", () -> { + try { + pm.getActivityInfo(component, PackageManager.GET_META_DATA); + } catch (NameNotFoundException e) { + throw new RuntimeException(e); + } + }); + } } |