• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2# Copyright (C) 2018 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 at
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 os import sys, path
17
18import synth_common
19
20trace = synth_common.create_trace()
21trace.add_packet()
22trace.add_process(1, 0, 'init')
23trace.add_process(2, 1, 'system_server')
24trace.add_process(3, 1, 'com.google.android.calendar', 10001)
25trace.add_process(4, 1, 'com.google.android.calendar')
26
27trace.add_package_list(
28    ts=1, name='com.google.android.calendar', uid=10001, version_code=123)
29
30trace.add_ftrace_packet(cpu=0)
31# Intent without any corresponding end state, will be ignored
32trace.add_atrace_begin(
33    ts=100, tid=2, pid=2, buf='MetricsLogger:launchObserverNotifyIntentStarted')
34trace.add_atrace_end(ts=101, tid=2, pid=2)
35
36# Start intent for a successful launch of calendar
37trace.add_atrace_begin(
38    ts=102, tid=2, pid=2, buf='MetricsLogger:launchObserverNotifyIntentStarted')
39trace.add_atrace_end(ts=103, tid=2, pid=2)
40
41trace.add_atrace_async_begin(
42    ts=110, tid=2, pid=2, buf='launching: com.google.android.calendar')
43
44trace.add_sched(ts=110, prev_pid=0, next_pid=3)
45# P1: 10ns running
46trace.add_sched(ts=120, prev_pid=3, next_pid=0, prev_state='S')
47# P1: 10ns sleep
48trace.add_sched(ts=130, prev_pid=0, next_pid=3)
49
50trace.add_sched(ts=130, prev_pid=3, next_pid=4)
51
52# Create an unrelated task
53trace.add_newtask(ts=155, tid=1, new_tid=5, new_comm='', flags=0)
54
55# P2: 30ns running
56trace.add_sched(ts=160, prev_pid=4, next_pid=0, prev_state='R')
57# P2: 49ns runnable
58trace.add_sched(ts=209, prev_pid=0, next_pid=4)
59# P2: 1ns running
60trace.add_sched(ts=210, prev_pid=4, next_pid=0)
61
62trace.add_atrace_async_end(
63    ts=210, tid=2, pid=2, buf='launching: com.google.android.calendar')
64trace.add_atrace_begin(
65    ts=211,
66    tid=2,
67    pid=2,
68    buf='MetricsLogger:launchObserverNotifyActivityLaunchFinished')
69trace.add_atrace_end(ts=212, tid=2, pid=2)
70
71# Some time after, add a slice for fully drawn frame.
72trace.add_atrace_begin(
73    ts=300,
74    tid=3,
75    pid=3,
76    buf='reportFullyDrawn() for \{com.google.android.calendar\}')
77trace.add_atrace_end(ts=305, tid=2, pid=2)
78
79# Start intent for calendar, we failed to launch the activity.
80trace.add_atrace_begin(
81    ts=402, tid=2, pid=2, buf='MetricsLogger:launchObserverNotifyIntentStarted')
82trace.add_atrace_end(ts=403, tid=2, pid=2)
83
84trace.add_atrace_async_begin(
85    ts=410, tid=2, pid=2, buf='launching: com.google.android.calendar')
86
87trace.add_atrace_async_end(
88    ts=510,
89    tid=2,
90    pid=2,
91    buf='launching: com.google.android.apps.nexuslauncher')
92
93trace.add_ftrace_packet(cpu=1)
94trace.add_sched(ts=160, prev_pid=0, next_pid=1)
95trace.add_sched(ts=200, prev_pid=1, next_pid=0)
96
97sys.stdout.buffer.write(trace.trace.SerializeToString())
98