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 os import sys 17 18import synth_common 19 20from synth_common import ms_to_ns 21 22trace = synth_common.create_trace() 23 24async_track_id = 1 25process_track = 2 26pid = 3 27thread_track = 4 28tid = 5 29seq = 6 30 31trace.add_track_descriptor(async_track_id) 32trace.add_process_track_descriptor( 33 process_track, pid=pid, process_name="Process") 34trace.add_thread_track_descriptor( 35 process_track, thread_track, tid=tid, pid=pid, thread_name="Thread") 36 37trace.add_track_event_slice("AsyncSlice", ts=1, dur=2, track=async_track_id) 38trace.add_track_event_slice("ProcessSlice", ts=3, dur=4, track=process_track) 39trace.add_track_event_slice("ThreadSlice", ts=5, dur=6, track=thread_track) 40 41sys.stdout.buffer.write(trace.trace.SerializeToString()) 42