• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2# Copyright (C) 2023 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License a
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16from python.generators.diff_tests.testing import Path, DataPath, Metric
17from python.generators.diff_tests.testing import Csv, Json, TextProto
18from python.generators.diff_tests.testing import DiffTestBlueprint
19from python.generators.diff_tests.testing import TestSuite
20
21
22class StartupMetrics(TestSuite):
23
24  def test_android_startup(self):
25    return DiffTestBlueprint(
26        trace=Path('android_startup.py'),
27        query=Metric('android_startup'),
28        out=Path('android_startup.out'))
29
30  def test_android_startup_slow(self):
31    return DiffTestBlueprint(
32        trace=Path('android_startup_slow.py'),
33        query=Metric('android_startup'),
34        out=Path('android_startup_slow.out'))
35
36  def test_android_startup_minsdk33(self):
37    return DiffTestBlueprint(
38        trace=Path('android_startup_minsdk33.py'),
39        query=Metric('android_startup'),
40        out=Path('android_startup_minsdk33.out'))
41
42  def test_android_startup_breakdown(self):
43    return DiffTestBlueprint(
44        trace=Path('android_startup_breakdown.py'),
45        query=Metric('android_startup'),
46        out=Path('android_startup_breakdown.out'))
47
48  def test_android_startup_breakdown_slow(self):
49    return DiffTestBlueprint(
50        trace=Path('android_startup_breakdown_slow.py'),
51        query=Metric('android_startup'),
52        out=Path('android_startup_breakdown_slow.out'))
53
54  def test_android_startup_process_track(self):
55    return DiffTestBlueprint(
56        trace=Path('android_startup_process_track.py'),
57        query=Metric('android_startup'),
58        out=Path('android_startup_process_track.out'))
59
60  def test_android_startup_attribution(self):
61    return DiffTestBlueprint(
62        trace=Path('android_startup_attribution.py'),
63        query=Metric('android_startup'),
64        out=Path('android_startup_attribution.out'))
65
66  def test_android_startup_attribution_slow(self):
67    return DiffTestBlueprint(
68        trace=Path('android_startup_attribution_slow.py'),
69        query=Metric('android_startup'),
70        out=Path('android_startup_attribution_slow.out'))
71
72  # Other metrics associated with startup.
73  def test_android_batt_counters(self):
74    return DiffTestBlueprint(
75        trace=Path('android_startup_battery.py'),
76        query=Metric('android_batt'),
77        out=TextProto(r"""
78        android_batt{
79           battery_counters{
80              timestamp_ns: 20
81              charge_counter_uah: 52
82              capacity_percent: 0.2
83              current_ua: 10
84              current_avg_ua: 12
85           }
86           battery_counters {
87              timestamp_ns: 52
88              charge_counter_uah: 32
89              capacity_percent: 0.8
90              current_ua: 8
91              current_avg_ua: 93
92           }
93           battery_counters {
94              timestamp_ns: 80
95              charge_counter_uah: 15
96              capacity_percent: 0.5
97              current_ua: 9
98              current_avg_ua: 5
99           }
100           battery_counters {
101              timestamp_ns: 92
102              charge_counter_uah: 21
103              capacity_percent: 0.3
104              current_avg_ua: 25
105           }
106        }
107        """))
108
109  def test_android_startup_cpu(self):
110    return DiffTestBlueprint(
111        trace=Path('android_startup_cpu.py'),
112        query=Metric('android_cpu'),
113        out=Path('android_startup_cpu.out'))
114
115  def test_android_startup_powrails(self):
116    return DiffTestBlueprint(
117        trace=Path('android_startup_powrails.py'),
118        query=Metric('android_powrails'),
119        out=Path('android_startup_powrails.out'))
120