Merge "Add task-args(from yaml file) candidates in /api/v2/yardstick/testcases API"
[yardstick.git] / yardstick / benchmark / scenarios / compute / ramspeed_mark_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 OUTPUT_FILE=/tmp/ramspeed-out.log
21
22 run_ramspeed()
23 {
24     cd /opt/tempT/RAMspeed/ramspeed-2.6.0/
25     ./ramspeed -b $TYPE_ID -g $LOAD -m $BLOCK_SIZE > $OUTPUT_FILE
26 }
27
28 # write the result to stdout in json format
29 output_json()
30 {
31    SCORE=$(awk '/  /{printf "{\"Test_type\": \"%s %s %s\", \"Block_size(kb)\": %s, \"Bandwidth(MBps)\": %s},", $1, $2, $3, $4, $7}' $OUTPUT_FILE)
32    echo -e "{ \
33        \"Result\":[${SCORE%?}] \
34    }"
35 }
36
37 main()
38 {
39     # run the test
40     run_ramspeed
41
42     #output result
43     output_json
44 }
45
46 main