aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/benchmark/scenarios/compute/ramspeed_mem_benchmark.bash
blob: 931a0637546662d4f0f9891c6c41f97b1436ed5a (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
47
#!/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
ITERATION=$4
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 -l $ITERATION > $OUTPUT_FILE
}

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

main()
{
    # run the test
    run_ramspeed

    # output result
    output_json
}

main