1#!/usr/bin/env python3 2# Copyright (C) 2021 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 19from synth_common import s_to_ns 20 21trace = synth_common.create_trace() 22 23trace.add_chrome_metadata(os_name="Android") 24 25track1 = 1234 26gpu_track = 7890 27 28trace.add_process_track_descriptor(track1, pid=0) 29trace.add_process_track_descriptor(gpu_track, pid=4) 30 31trace.add_rail_mode_slice( 32 ts=0, 33 dur=s_to_ns(1), 34 track=track1, 35 mode=trace.prototypes.ChromeRAILMode.RAIL_MODE_RESPONSE) 36trace.add_rail_mode_slice( 37 ts=s_to_ns(1), 38 dur=-1, 39 track=track1, 40 mode=trace.prototypes.ChromeRAILMode.RAIL_MODE_IDLE) 41 42# Generate an extra trace event long after events on the renderer process have 43# ceased to ensure that the RAIL mode is extended to the end of the process 44# rather than the end of the trace itself. 45trace.add_track_event_slice("VSync", ts=s_to_ns(25), dur=10, track=gpu_track) 46 47sys.stdout.buffer.write(trace.trace.SerializeToString()) 48