aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/benchmark/scenarios/compute/lmbench_bandwidth_benchmark.bash
blob: 1a25121c762f710b943f29fffdebbc7343bc1a44 (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
#!/bin/bash

##############################################################################
# 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
##############################################################################

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

set -e

SIZE=$1
TEST_NAME=$2
WARMUP=$3

NODE_CPU_ARCH="$(uname -m)"

# write the result to stdout in json format
output_json()
{
    read DATA
    echo $DATA | awk '/ /{printf "{\"size(MB)\": %s, \"bandwidth(MBps)\": %s}", $1, $2}'
}

if [ "${NODE_CPU_ARCH}" == "aarch64" ]; then
    REL_PATH="bw_mem"
else
    REL_PATH="x86_64-linux-gnu/bw_mem"
fi

/usr/lib/lmbench/bin/${REL_PATH} -W $WARMUP ${SIZE}k $TEST_NAME 2>&1 | output_json