File: test-perf

package info (click to toggle)
btest 0.72-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,208 kB
  • sloc: python: 2,187; sh: 547; makefile: 165; xml: 12; awk: 1
file content (40 lines) | stat: -rwxr-xr-x 849 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#! /usr/bin/env bash
#
# This script imitates the behavior of the Linux "perf" command.  Useful
# for testing purposes because this script produces consistent and
# predictable results.
#
# NOTE: if this script is in PATH, then it should not be named "perf", because
# we want to use the real perf command for some tests.

# Only "perf stat" is supported.
if [ "$1" != "stat" ]; then
    exit 1
fi
shift

# Ignore all options except "-o".
while getopts "o:x:e:" arg; do
    case $arg in
        o)
            fname=$OPTARG
            ;;
        *) ;;

    esac
done

shift $((OPTIND - 1))

# Use a hard-coded message so that we get predictable results
msg="1000  instructions"

# Write the message to a file (if specified), or stderr
if [ -n "$fname" ]; then
    echo "$msg" >"$fname"
else
    echo "$msg" >&2
fi

# Run the specified command
"$@"