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