data_netperf.py 2.32 KB
Newer Older
Hejing Li's avatar
Hejing Li committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Copyright 2021 Max Planck Institute for Software Systems, and
# National University of Singapore
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

import sys
Jonas Kaufmann's avatar
Jonas Kaufmann committed
24
25
from time import gmtime, strftime

26
from utils.netperf import parse_netperf_run
Hejing Li's avatar
Hejing Li committed
27
28
29
30
31
32
33
34


def fmt_lat(lat):
    if not lat:
        return ''

    x = float(lat)
    if x >= 1000.:
35
        return f'{x / 1000:.1f}\\,ms'
Hejing Li's avatar
Hejing Li committed
36
    else:
37
        return f'{int(x)}\\,$\\mu$s'
Hejing Li's avatar
Hejing Li committed
38
39


40
# pylint: disable=redefined-outer-name
Hejing Li's avatar
Hejing Li committed
41
42
43
44
45
46
def fmt_tp(tp):
    if not tp:
        return ''

    x = float(tp)
    if x > 1000.:
47
        return f'{x / 1000:.2f}\\,G'
Hejing Li's avatar
Hejing Li committed
48
    else:
49
        return f'{int(x)}\\,M'
Hejing Li's avatar
Hejing Li committed
50
51
52
53
54
55
56
57
58
59
60


hosts = [('qemu', 'QK'), ('qt', 'QT'), ('gt', 'G5')]
nics = [('ib', 'IB'), ('cb', 'CB'), ('cv', 'CV')]
nets = [('sw', 'SW'), ('ns3', 'NS')]

outdir = sys.argv[1]

for (h, h_l) in hosts:
    for (nic, nic_l) in nics:
        for (net, net_l) in nets:
61
            path = f'{outdir}/nf-{h}-{net}-{nic}-1.json'
Hejing Li's avatar
Hejing Li committed
62
63
            data = parse_netperf_run(path)
            if 'simtime' in data:
Jonas Kaufmann's avatar
Jonas Kaufmann committed
64
                t = strftime('%H:%M:%S', gmtime(data['simtime']))
Hejing Li's avatar
Hejing Li committed
65
66
67
68
69
70
            else:
                t = ''

            tp = fmt_tp(data.get('throughput', ''))
            latMean = fmt_lat(data.get('latenyMean', ''))
            latTail = fmt_lat(data.get('latenyTail', ''))
71
            print(f'  {h_l} & {nic_l} & {net_l} & {tp} & {latMean} & {t} \\\\')