xref: /aosp_15_r20/external/angle/src/tests/restricted_traces/gpumem.sh (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1*8975f5c5SAndroid Build Coastguard Worker#!/bin/bash
2*8975f5c5SAndroid Build Coastguard Worker#
3*8975f5c5SAndroid Build Coastguard Worker# Copyright 2021 The ANGLE Project Authors. All rights reserved.
4*8975f5c5SAndroid Build Coastguard Worker# Use of this source code is governed by a BSD-style license that can be
5*8975f5c5SAndroid Build Coastguard Worker# found in the LICENSE file.
6*8975f5c5SAndroid Build Coastguard Worker#
7*8975f5c5SAndroid Build Coastguard Worker
8*8975f5c5SAndroid Build Coastguard Workersleep_duration=$1
9*8975f5c5SAndroid Build Coastguard Workerif [ -z "${sleep_duration}" ]; then
10*8975f5c5SAndroid Build Coastguard Worker    echo "No sleep_duration provided"
11*8975f5c5SAndroid Build Coastguard Worker    exit 1
12*8975f5c5SAndroid Build Coastguard Workerfi
13*8975f5c5SAndroid Build Coastguard Worker
14*8975f5c5SAndroid Build Coastguard Workerstorage_dir=$2
15*8975f5c5SAndroid Build Coastguard Workerif [ -z "${storage_dir}" ]; then
16*8975f5c5SAndroid Build Coastguard Worker    echo "No storage_dir provided"
17*8975f5c5SAndroid Build Coastguard Worker    exit 1
18*8975f5c5SAndroid Build Coastguard Workerfi
19*8975f5c5SAndroid Build Coastguard Worker
20*8975f5c5SAndroid Build Coastguard Workerstart_time=$SECONDS
21*8975f5c5SAndroid Build Coastguard Workerwhile true; do
22*8975f5c5SAndroid Build Coastguard Worker    pid=$(pidof com.android.angle.test:test_process)
23*8975f5c5SAndroid Build Coastguard Worker    case $pid in
24*8975f5c5SAndroid Build Coastguard Worker        ''|*[!0-9]*) echo pid is not a number ;;
25*8975f5c5SAndroid Build Coastguard Worker        *) echo com.android.angle.test:test_process $pid >> ${storage_dir}/gpumem.txt ;;
26*8975f5c5SAndroid Build Coastguard Worker    esac
27*8975f5c5SAndroid Build Coastguard Worker    dumpsys gpu --gpumem >> ${storage_dir}/gpumem.txt
28*8975f5c5SAndroid Build Coastguard Worker    time_elapsed=$(( SECONDS - start_time ))
29*8975f5c5SAndroid Build Coastguard Worker    echo "time_elapsed: $time_elapsed" >> ${storage_dir}/gpumem.txt
30*8975f5c5SAndroid Build Coastguard Worker    sleep ${sleep_duration};
31*8975f5c5SAndroid Build Coastguard Workerdone
32