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