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.abspath(__file__))) 19import synth_common 20 21file_member = 0 22anon_member = 1 23 24trace = synth_common.create_trace() 25trace.add_process_tree_packet() 26trace.add_process(1, 0, "init") 27trace.add_process(2, 1, "process_a") 28trace.add_process(3, 1, "process_b") 29 30trace.add_ftrace_packet(0) 31trace.add_rss_stat(100, 2, file_member, 100) 32trace.add_rss_stat(100, 2, anon_member, 200) 33trace.add_oom_score_update(100, 1000, 2) 34trace.add_rss_stat(105, 2, file_member, 50) 35trace.add_oom_score_update(107, -300, 2) 36trace.add_rss_stat(110, 2, anon_member, 100) 37trace.add_rss_stat(120, 2, anon_member, 75) 38trace.add_rss_stat(121, 2, file_member, 95) 39trace.add_oom_score_update(122, 300, 2) 40trace.add_rss_stat(123, 2, anon_member, 200) 41trace.add_rss_stat(124, 2, file_member, 75) 42trace.add_rss_stat(125, 2, file_member, 35) 43trace.add_oom_score_update(126, 0, 2) 44trace.add_rss_stat(126, 2, file_member, 0) 45trace.add_rss_stat(126, 2, anon_member, 0) 46 47trace.add_ftrace_packet(0) 48trace.add_rss_stat(104, 3, file_member, 400) 49trace.add_rss_stat(107, 3, anon_member, 300) 50trace.add_oom_score_update(110, 0, 3) 51trace.add_rss_stat(113, 3, file_member, 75) 52trace.add_rss_stat(114, 3, anon_member, 800) 53trace.add_oom_score_update(115, 600, 3) 54trace.add_rss_stat(117, 3, file_member, 25) 55trace.add_rss_stat(118, 3, file_member, 80) 56trace.add_oom_score_update(118, -500, 3) 57trace.add_rss_stat(123, 3, file_member, 85) 58trace.add_rss_stat(126, 3, anon_member, 600) 59trace.add_rss_stat(129, 3, file_member, 90) 60trace.add_oom_score_update(130, 200, 3) 61trace.add_rss_stat(130, 2, file_member, 0) 62trace.add_rss_stat(130, 2, anon_member, 0) 63 64 65print(trace.trace.SerializeToString()) 66