aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/benchmark/scenarios/compute/ramspeed_mark_benchmark.bash
blob: 526d0b9f65d65d12d34e0ab996622a65c332f83c (plain)
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
41
42
43
44
45
46
#!/bin/bash

##############################################################################
# Copyright (c) 2016 Huawei Technologies Co.,Ltd 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
##############################################################################

# Run a ramspeed memory bandwidth benchmark in a host and
# output in json format the memory bandwidth in megabytes per second

set -e

TYPE_ID=$1
LOAD=$2
BLOCK_SIZE=$3
OUTPUT_FILE=/tmp/ramspeed-out.log

run_ramspeed()
{
    cd /opt/tempT/RAMspeed/ramspeed-2.6.0/
    ./ramspeed -b $TYPE_ID -g $LOAD -m $BLOCK_SIZE > $OUTPUT_FILE
}

# write the result to stdout in json format
output_json()
{
   SCORE=$(awk '/  /{printf "{\"Test_type\": \"%s %s %s\", \"Block_size(kb)\": %s, \"Bandwidth(MBps)\": %s},", $1, $2, $3, $4, $7}' $OUTPUT_FILE)
   echo -e "{ \
       \"Result\":[${SCORE%?}] \
   }"
}

main()
{
    # run the test
    run_ramspeed

    #output result
    output_json
}

main