blob: 0b1e1be0a1362468917afdca8690013c5d368a33 [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: ProfileAThread.sh <process_name> <period> <perf_command>
# e.g. ProfileAThread.sh <process_name> <period> <perf_command>
#
# 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: ProfileAThread.sh <process_name> <period> <perf_command>"
echo "e.g. ProfileAThread.sh parking_task 0.45 perf"
else
pid=$(pgrep -f $process_name -o)
$perf_command stat -e instructions:u -p $pid -- sleep $period
fi