Merge "Update plotter.py to new yardstick.out format"
[yardstick.git] / yardstick / benchmark / scenarios / compute / ramspeed_mem_benchmark.bash
1 #!/bin/bash
2
3 ##############################################################################
4 # Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
5 #
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Apache License, Version 2.0
8 # which accompanies this distribution, and is available at
9 # http://www.apache.org/licenses/LICENSE-2.0
10 ##############################################################################
11
12 # Run a ramspeed memory bandwidth benchmark in a host and
13 # output in json format the memory bandwidth in megabytes per second
14
15 set -e
16
17 TYPE_ID=$1
18 LOAD=$2
19 BLOCK_SIZE=$3
20 ITERATION=$4
21 OUTPUT_FILE=/tmp/ramspeed-out.log
22
23 run_ramspeed()
24 {
25     cd /opt/tempT/RAMspeed/ramspeed-2.6.0/
26     ./ramspeed -b $TYPE_ID -g $LOAD -m $BLOCK_SIZE -l $ITERATION > $OUTPUT_FILE
27 }
28
29 # write the result to stdout in json format
30 output_json()
31 {
32    SCORE=$(awk '/  /{printf "{\"Test_type\": \"%s %s\", \"Bandwidth(MBps)\": %s},", $1, $2, $3}' $OUTPUT_FILE)
33    echo -e "{ \
34       \"Result\":[${SCORE%?}] \
35    }"
36 }
37
38 main()
39 {
40     # run the test
41     run_ramspeed
42
43     # output result
44     output_json
45 }
46
47 main