# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# +
# %matplotlib inline 

import os
import re
import csv

import pandas as pd 
import seaborn as sns 


# -

def parse_server_log(path):
    clipat = re.compile(r'^(\d+) clients$')
    conpat = re.compile(r'^\[honu\] ([\d\.:]+) created (\w+) consistency storage$')
    thrpat = re.compile(r'^\[honu\] ([\d\.:]+) (\d+) accesses \(\d+ reads, \d+ writes\) in ([\d\.]+)s -- ([\d\.]+) accesses/second$')

    clients = None 
    consistency = None 
    
    with open(path, 'r') as f:
        for line in f:
            line = line.strip() 
            
            match = clipat.match(line)
            if match is not None:
                clients = match.groups()[0]
            
            match = conpat.match(line)
            if match is not None:
                consistency = match.groups()[1]
            
            match = thrpat.match(line)
            if match is not None:
                yield {
                    "clients": clients, 
                    "consistency": consistency, 
                    "accesses": int(match.groups()[1]),
                    "seconds": float(match.groups()[2]),
                    "throughput (accesses/sec)": float(match.groups()[3]),
                }


with open('server-throughput.csv', 'w') as out:
    writer = csv.DictWriter(out, fieldnames=("clients", "consistency", "accesses", "seconds", "throughput (accesses/sec)"))
    writer.writeheader()
    
    for path in ('server-lin.log', 'server-seq.log'):
        for row in parse_server_log(path):
            writer.writerow(row)

data = pd.read_csv('server-throughput.csv')

data.dtypes

data.describe()

sns.set_style('whitegrid')
sns.set_context('poster')

g = sns.lmplot(x="clients", y="throughput (accesses/sec)", hue="consistency", logx=True, size=8, aspect=2.4, data=data)
g.axes[0][0].set_title("Throughput on a Virtual Machine")
g.axes[0][0].set_ylim(0,21000)

g.axes

StarcoderdataJupyterScriptsDedupFiltered