#!/usr/bin/env python3

import sys
import matplotlib.pyplot as plt
import pandas as pd

df = pd.concat(pd.read_csv(f) for f in sys.argv[1:])
print(df)

grp = df.groupby('tbl')
print(grp['hit'].mean())
print(grp['time'].mean())
print(grp['read'].mean())
print(grp['iotime'].mean())

fig, axs = plt.subplots(1, 4, figsize=(16, 6))

stats = {
    'hit': 'Shared block hits',
    'time':'Execution time in ms',
    'read': 'Shared block reads',
    'iotime': 'I/O read time in ms'
}

for index, (name, desc) in enumerate(stats.items()):
    df.boxplot(by='tbl', ax=axs[index], column=name, rot=45, showfliers=False)
    axs[index].set_xlabel('')
    axs[index].set_ylabel(desc)

plt.tight_layout(w_pad=4)
plt.suptitle('Sortsupport for range types and btree_gist')
plt.show()
