File: parse_output.py

package info (click to toggle)
libatomic-queue 0.0%2Bgit20220518.83774a2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 10,352 kB
  • sloc: cpp: 1,620; javascript: 353; makefile: 131; python: 82; ansic: 74; sh: 59
file content (30 lines) | stat: -rwxr-xr-x 913 bytes parent folder | download | duplicates (9)
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
#!/usr/bin/env python

# Copyright (c) 2019 Maxim Egorushkin. MIT License. See the full licence in file LICENSE.

import re
import pandas as pd

_parser = re.compile("\s*(.+):\s+([,.0-9]+)\s+(\S+)")

def parse_output(f):
    for line in f:
        m = _parser.match(line)
        if m:
            queue = m.group(1)
            units = m.group(3)
            value = float(m.group(2).replace(',', ''))
            yield queue, units, value


def extract_name_threads(name_theads):
    name, threads, si = name_theads.split(',')
    return name, int(threads)


def as_scalability_df(results):
    return pd.DataFrame.from_records(((*extract_name_threads(r[0]), r[2]) for r in results if r[1] == 'msg/sec'), columns=['queue', 'threads', 'msg/sec'])


def as_latency_df(results):
    return pd.DataFrame.from_records(((r[0], r[2]) for r in results if r[1] == 'sec/round-trip'), columns=['queue', 'sec/round-trip'])