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 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', 10003) 25trace.add_process(4, 1, 'com.google.android.calculator', 10004) 26trace.add_process(5, 1, 'com.google.android.deskclock', 10005) 27trace.add_process(6, 1, 'com.google.android.gm', 10006) 28trace.add_process(10, 1, 'dex2oat64') 29trace.add_process(11, 1, 'installd') 30 31trace.add_package_list( 32 ts=1, name='com.google.android.calendar', uid=10003, version_code=123) 33trace.add_package_list( 34 ts=2, name='com.google.android.calculator', uid=10004, version_code=123) 35trace.add_package_list( 36 ts=3, name='com.google.android.deskclock', uid=10005, version_code=123) 37trace.add_package_list( 38 ts=4, name='com.google.android.gm', uid=10006, version_code=123) 39 40trace.add_ftrace_packet(cpu=0) 41 42# First launch: don't have either dex2oat or installd 43trace.add_atrace_async_begin(ts=100, tid=2, pid=2, buf='launchingActivity#1') 44trace.add_atrace_async_end(ts=200, tid=2, pid=2, buf='launchingActivity#1') 45trace.add_atrace_instant( 46 ts=201, 47 tid=2, 48 pid=2, 49 buf='launchingActivity#1:completed:com.google.android.calendar') 50 51# Second launch: just dex2oat 52trace.add_atrace_async_begin(ts=300, tid=2, pid=2, buf='launchingActivity#2') 53trace.add_sched(ts=305, prev_pid=0, next_pid=10) 54trace.add_sched(ts=310, prev_pid=10, next_pid=0) 55trace.add_atrace_async_end(ts=400, tid=2, pid=2, buf='launchingActivity#2') 56trace.add_atrace_instant( 57 ts=401, 58 tid=2, 59 pid=2, 60 buf='launchingActivity#2:completed:com.google.android.calculator') 61 62# Third launch: just installd 63trace.add_atrace_async_begin(ts=500, tid=2, pid=2, buf='launchingActivity#3') 64trace.add_sched(ts=505, prev_pid=0, next_pid=11) 65trace.add_sched(ts=510, prev_pid=11, next_pid=0) 66trace.add_atrace_async_end(ts=600, tid=2, pid=2, buf='launchingActivity#3') 67trace.add_atrace_instant( 68 ts=601, 69 tid=2, 70 pid=2, 71 buf='launchingActivity#3:completed:com.google.android.deskclock') 72 73# Third launch: just installd 74trace.add_atrace_async_begin(ts=700, tid=2, pid=2, buf='launchingActivity#4') 75trace.add_sched(ts=705, prev_pid=0, next_pid=10) 76trace.add_sched(ts=710, prev_pid=10, next_pid=0) 77trace.add_sched(ts=715, prev_pid=0, next_pid=11) 78trace.add_sched(ts=720, prev_pid=11, next_pid=0) 79trace.add_atrace_async_end(ts=800, tid=2, pid=2, buf='launchingActivity#4') 80trace.add_atrace_instant( 81 ts=801, 82 tid=2, 83 pid=2, 84 buf='launchingActivity#4:completed:com.google.android.gm') 85 86sys.stdout.buffer.write(trace.trace.SerializeToString()) 87