<jupyter_start><jupyter_text>Microbenchmark Experiment Analysis  Notebook Configuration<jupyter_code>########## GENERAL
# Experiment directory path
EXPERIMENT_DIRPATH = "sample"

########## EXECUTION LOGS
# Function to aggregate PIT data
PIT_AGGREGATE_FUNC = "mean"<jupyter_output><empty_output><jupyter_text>Notebook Setup<jupyter_code># Import libraries
%matplotlib inline
import matplotlib.pyplot as plt
import os
import pandas as pd
import warnings
warnings.filterwarnings("ignore")<jupyter_output><empty_output><jupyter_text>Execution Logs<jupyter_code># List microbenchmarks in the experiment directory (CSV files).
microbenchmarks = [filename.split(".")[0] for filename in os.listdir(EXPERIMENT_DIRPATH)
                   if os.path.isfile(os.path.join(EXPERIMENT_DIRPATH, filename)) and filename.endswith(".csv")]

########## UTILITIES
def load_microbenchmark_logs(microbenchmark):
    "Return a DataFrame with execution logs of the specified microbenchmark."
    df = pd.read_csv(os.path.join(EXPERIMENT_DIRPATH, microbenchmark + ".csv"))
    return df<jupyter_output><empty_output><jupyter_text>Workload Rate<jupyter_code>fig = plt.figure(figsize=(32, 64))
for (i, microbenchmark) in enumerate(microbenchmarks):
    df = load_microbenchmark_logs(microbenchmark)
    df["window"] = df.apply(lambda r: int(r["timestamp_milli"] / 1000), axis=1)
    df = df.groupby(["window", "status"])["window"].count().unstack().fillna(0)
    df = df.reindex(range(0, int(df.index.max()) + 1), fill_value=0)
    ax = fig.add_subplot(len(microbenchmarks), 1, i + 1)
    ax.grid(alpha=0.75)
    df.plot(ax=ax, kind="bar", stacked=True, title="%s microbenchmark - Workload Rate" % microbenchmark,
            xlabel="Time (seconds)", ylabel="Requests per second",
            color={"failed": "red", "succeeded": "blue"}, legend=True, grid=True,
            xticks=range(0, int(df.index.max()) + 1, 10))<jupyter_output><empty_output><jupyter_text>Point-in-Time Execution Time (Only Successful Requests)<jupyter_code>fig = plt.figure(figsize=(32, 64))
for (i, microbenchmark) in enumerate(microbenchmarks):
    df = load_microbenchmark_logs(microbenchmark)
    df = df[df["status"] == "succeeded"]
    df["window"] = df.apply(lambda r: int(r["timestamp_milli"] / 1000), axis=1)
    df = df.groupby(["window"])["exec_time_milli"].agg(PIT_AGGREGATE_FUNC)
    df = df.reindex(range(0, int(df.index.max()) + 1), fill_value=0)
    ax = fig.add_subplot(len(microbenchmarks), 1, i + 1)
    ax.grid(alpha=0.75)
    df.plot(ax=ax, kind="bar", title="%s microbenchmark - PIT Execution Time" % microbenchmark,
            xlabel="Time (seconds)", ylabel="Execution Time (milliseconds)",
            color="purple", grid=True,
            xticks=range(0, int(df.index.max()) + 1, 60))<jupyter_output><empty_output><jupyter_text>Execution Time Distribution (Only Successful Requests)<jupyter_code>fig = plt.figure(figsize=(32, 64))
for (i, microbenchmark) in enumerate(microbenchmarks):
    df = load_microbenchmark_logs(microbenchmark)
    df = df[df["status"] == "succeeded"]
    df["exec_time_bin"] = df.apply(lambda r: int(r["exec_time_milli"]), axis=1)
    ax = fig.add_subplot(len(microbenchmarks), 1, i + 1)
    ax.grid(alpha=0.75)
    ax.set_xlim((0, df["exec_time_bin"].max()))
    df["exec_time_bin"].plot(ax=ax, kind="hist",
                             title="%s microbenchmark - Execution Time Distribution" % microbenchmark,
                             xlabel="Execution Time (milliseconds)", ylabel="Count",
                             bins=range(df["exec_time_bin"].max()),
                             grid=True)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1520065970313359, 'fraction_numerical': 0.015118196811434854, 'mean_word_length': 4.650621118012422, 'pattern_counts': {'":': 2, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '375239', 'license': 'Apache-2.0', 'n_tokens_mistral': 1296, 'n_tokens_neox': 1228, 'n_words': 229, 'path': 'analysis/Microbenchmark.ipynb', 'repo_name': 'rodrigoalveslima/cppmicrobench', 'size': '3638'}