Add send socket commands function
[yardstick.git] / yardstick / benchmark / scenarios / compute / lmbench_latency_benchmark.bash
1 #!/bin/bash
2
3 ##############################################################################
4 # Copyright (c) 2015 Ericsson AB 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 lmbench read memory latency benchmark in a host and
13 # outputs in json format the array sizes in megabytes and
14 # load latency over all points in that array in nanosecods
15
16 set -e
17
18 SIZE=$1
19 shift
20 STRIDE=$1
21
22 NODE_CPU_ARCH="$(uname -m)"
23
24 # write the result to stdout in json format
25 output_json()
26 {
27     iter=0
28     echo [
29     while read DATA
30     do
31         if [ $iter -gt 1 ] && [ -n "$DATA" ]; then
32             echo ,
33         fi
34
35         echo -n $DATA | awk '/ /{printf "{\"size\": %s, \"latency\": %s}", $1, $2}'
36
37         iter=$((iter+1))
38     done
39     echo ]
40 }
41
42 if [ "${NODE_CPU_ARCH}" == "aarch64" ]; then
43     /usr/lib/lmbench/bin/lat_mem_rd $SIZE $STRIDE 2>&1 | output_json
44 else
45     /usr/lib/lmbench/bin/x86_64-linux-gnu/lat_mem_rd $SIZE $STRIDE 2>&1 | output_json
46 fi