diff options
author | Kristian Hunt <kristian.hunt@gmail.com> | 2015-07-14 13:13:47 +0200 |
---|---|---|
committer | Jörgen Karlsson <jorgen.w.karlsson@ericsson.com> | 2015-08-13 13:23:55 +0000 |
commit | eca1e81cac34d7569fa5dcb15e5df10a6583559b (patch) | |
tree | b33491e7192b1f8a6d8293927fba6dae34d0b7d4 /yardstick/benchmark/scenarios/compute/perf_benchmark.bash | |
parent | ce671dba3dafe0d7d80d4a7eea1f9395bc4d6d7d (diff) |
Add perf scenario and sample
Supports using perf software event counters. No hardware events are
currently supported. It is possible to add some load to the system
using the load parameter, otherwise the system will sleep while the
measurements are collected.
It is possible to configure SLA for any event measured.
Change-Id: Ic413d940093aadd10dc32888ea416aa94316a6fe
JIRA: YARDSTICK-51
Signed-off-by: Kristian Hunt <kristian.hunt@gmail.com>
Diffstat (limited to 'yardstick/benchmark/scenarios/compute/perf_benchmark.bash')
-rw-r--r-- | yardstick/benchmark/scenarios/compute/perf_benchmark.bash | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/yardstick/benchmark/scenarios/compute/perf_benchmark.bash b/yardstick/benchmark/scenarios/compute/perf_benchmark.bash new file mode 100644 index 000000000..5ae107a52 --- /dev/null +++ b/yardstick/benchmark/scenarios/compute/perf_benchmark.bash @@ -0,0 +1,68 @@ +#!/bin/sh + +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +set -e + +# Commandline arguments +PAYLOAD_OP=$1 +shift +DURATION=$1 +shift +EVENTS=("$@") +OUTPUT_FILE=/tmp/perfout.txt + +# run perf test +run_perf() +{ + COMMA_SEP_E=$( IFS=$','; echo "${EVENTS[*]}" ) + + if [[ $PAYLOAD_OP == dd* ]] + then + sudo perf stat -o $OUTPUT_FILE -e ${COMMA_SEP_E[@]} $PAYLOAD_OP & + sleep $DURATION + sudo killall -q -u root dd + else + sudo perf stat -o $OUTPUT_FILE -e ${COMMA_SEP_E[@]} $PAYLOAD_OP + fi +} + +# write the result to stdout in json format +output_json() +{ + EVENTS+=('time') + + last_pos=$(( ${#EVENTS[*]} - 1 )) + last=${EVENTS[$last_pos]} + + echo -n { + for EVENT in ${EVENTS[@]} + do + value=$(cat $OUTPUT_FILE | grep $EVENT | awk 'match($0,/[0-9]+|[0-9]+\.[0-9]*/, a) { print a[0]}') + + if [[ $EVENT != $last ]] + then + echo -n \"$EVENT\": $value, + else + echo -n \"$EVENT\": $value + fi + done + echo } +} + +# main entry +main() +{ + run_perf > /dev/null 2>&1 + sleep 1 + output_json +} + +main |