blob: a0eae0c4144c7a22c32ec4cc9176e76e82bf824d [file] [log] [blame]
#!/bin/bash
# Copyright (c) 2017 FH Dortmund and others
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Description:
# This script is used for estimating the granularity of a thread by
# making use of its name and period.
# Right usage: ProfileThreadsOfAProcess.sh <process_name> <period> <perf_command>
# e.g. ProfileThreadsOfAProcess.sh <process_name> <period> <perf_command>
# <period> is in milliseconds
#
# Authors:
# M. Ozcelikors <mozcelikors@gmail.com>, FH Dortmund
#
args=("$@")
process_name=${args[0]}
period=${args[1]}
perf_command=${args[2]}
if [ "$#" -ne 3 ]; then
echo "Entered arguments seem to be incorrect"
echo "Right usage: ProfileThreadsOfAProcess.sh <process_name> <period> <perf_command>"
echo "e.g. ProfileThreadsOfAProcess.sh parking_task 450 perf"
echo "<period> is in milliseconds"
else
pid=$(pgrep -f $process_name -o)
$perf_command stat --per-thread -e instructions:u -p $pid -I $period
fi