-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from lambdaclass/bench-analysis
Improves logging and plots benchmark information
- Loading branch information
Showing
15 changed files
with
575 additions
and
23 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from argparse import ArgumentParser | ||
|
||
argument_parser = ArgumentParser('Stress Test Plotter') | ||
argument_parser.add_argument("native_logs_path") | ||
arguments = argument_parser.parse_args() | ||
|
||
import matplotlib.pyplot as plt | ||
import pandas as pd | ||
import seaborn as sns | ||
|
||
dataset = pd.read_json(arguments.native_logs_path, lines=True, typ="series") | ||
|
||
def canonicalize_compilation_time(event): | ||
if "contract compilation finished" not in event["fields"]["message"]: | ||
return None | ||
|
||
compilation_span = find_span(event, "contract compilation") | ||
if compilation_span is None: | ||
return None | ||
|
||
return { | ||
"class hash": compilation_span["class_hash"], | ||
"size": event["fields"]["size"] / (1024 * 1024), | ||
} | ||
|
||
def find_span(event, name): | ||
for span in event["spans"]: | ||
if name in span["name"]: | ||
return span | ||
return None | ||
|
||
def format_hash(class_hash): | ||
return f"0x{class_hash[:6]}..." | ||
|
||
|
||
dataset = dataset.apply(canonicalize_compilation_time).dropna().apply(pd.Series) | ||
|
||
figure, ax = plt.subplots() | ||
|
||
sns.set_color_codes("bright") | ||
sns.barplot(ax=ax, y="class hash", x="size", data=dataset, formatter=format_hash) # type: ignore | ||
|
||
ax.set_xlabel("Library Size (MiB)") | ||
ax.set_ylabel("Class Hash") | ||
ax.set_title("Library Size by Contract") | ||
|
||
plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
from argparse import ArgumentParser | ||
|
||
argument_parser = ArgumentParser('Stress Test Plotter') | ||
argument_parser.add_argument("native_logs_path") | ||
argument_parser.add_argument("vm_logs_path") | ||
arguments = argument_parser.parse_args() | ||
|
||
import matplotlib.pyplot as plt | ||
import pandas as pd | ||
import seaborn as sns | ||
|
||
dataset_native = pd.read_json(arguments.native_logs_path, lines=True, typ="series") | ||
dataset_vm = pd.read_json(arguments.vm_logs_path, lines=True, typ="series") | ||
|
||
def canonicalize_compilation_time(event): | ||
if "contract compilation finished" not in event["fields"]["message"]: | ||
return None | ||
|
||
compilation_span = find_span(event, "contract compilation") | ||
if compilation_span is None: | ||
return None | ||
|
||
return { | ||
"class hash": compilation_span["class_hash"], | ||
"size": event["fields"]["size"] / 1024, | ||
} | ||
|
||
def find_span(event, name): | ||
for span in event["spans"]: | ||
if name in span["name"]: | ||
return span | ||
return None | ||
|
||
def format_hash(class_hash): | ||
return f"0x{class_hash[:6]}..." | ||
|
||
|
||
dataset_native = dataset_native.apply(canonicalize_compilation_time).dropna().apply(pd.Series) | ||
dataset_vm = dataset_vm.apply(canonicalize_compilation_time).dropna().apply(pd.Series) | ||
|
||
dataset_native = dataset_native.set_index("class hash") | ||
dataset_vm = dataset_vm.set_index("class hash") | ||
|
||
dataset = dataset_native.join(dataset_vm, lsuffix="_native", rsuffix="_casm") | ||
|
||
figure, ax = plt.subplots() | ||
|
||
sns.set_color_codes("bright") | ||
|
||
sns.regplot( | ||
x="size_native", | ||
y="size_casm", | ||
label = "Native (<1000)", | ||
data=dataset[dataset["size_native"] < 1000], | ||
ax = ax, | ||
) | ||
sns.regplot( | ||
x="size_native", | ||
y="size_casm", | ||
label = "Native (>=1000)", | ||
data=dataset[dataset["size_native"] >= 1000], | ||
ax = ax, | ||
) | ||
|
||
ax.set_xlabel("Native Compilation Size (KiB)") | ||
ax.set_ylabel("Casm Compilation Size (KiB)") | ||
ax.set_title("Compilation Size Correlation") | ||
|
||
ax.legend() | ||
|
||
plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
from argparse import ArgumentParser | ||
|
||
argument_parser = ArgumentParser('Stress Test Plotter') | ||
argument_parser.add_argument("native_logs_path") | ||
argument_parser.add_argument("vm_logs_path") | ||
arguments = argument_parser.parse_args() | ||
|
||
import matplotlib.pyplot as plt | ||
import pandas as pd | ||
import seaborn as sns | ||
|
||
dataset_native = pd.read_json(arguments.native_logs_path, lines=True, typ="series") | ||
dataset_vm = pd.read_json(arguments.vm_logs_path, lines=True, typ="series") | ||
|
||
def canonicalize_compilation_time(event): | ||
if "contract compilation finished" not in event["fields"]["message"]: | ||
return None | ||
|
||
compilation_span = find_span(event, "contract compilation") | ||
if compilation_span is None: | ||
return None | ||
|
||
return { | ||
"class hash": compilation_span["class_hash"], | ||
"length": compilation_span["length"] / 1024, | ||
"size": event["fields"]["size"] / 1024, | ||
} | ||
|
||
def find_span(event, name): | ||
for span in event["spans"]: | ||
if name in span["name"]: | ||
return span | ||
return None | ||
|
||
def format_hash(class_hash): | ||
return f"0x{class_hash[:6]}..." | ||
|
||
|
||
dataset_native = dataset_native.apply(canonicalize_compilation_time).dropna().apply(pd.Series) | ||
dataset_vm = dataset_vm.apply(canonicalize_compilation_time).dropna().apply(pd.Series) | ||
|
||
figure, ax = plt.subplots() | ||
|
||
sns.set_color_codes("bright") | ||
|
||
sns.regplot( | ||
x="length", | ||
y="size", | ||
label = "Native (<1000)", | ||
data=dataset_native[dataset_native["size"] < 1000], | ||
ax = ax, | ||
) | ||
sns.regplot( | ||
x="length", | ||
y="size", | ||
label = "Native (>=1000)", | ||
data=dataset_native[dataset_native["size"] >= 1000], | ||
ax = ax, | ||
) | ||
sns.regplot( | ||
x="length", | ||
y="size", | ||
label = "Casm", | ||
data=dataset_vm, | ||
ax = ax, | ||
) | ||
|
||
ax.set_xlabel("Sierra size (KiB)") | ||
ax.set_ylabel("Compiled size (KiB)") | ||
ax.set_title("Compilation Size Trend") | ||
ax.ticklabel_format(style="plain") | ||
|
||
|
||
ax.legend() | ||
|
||
plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from argparse import ArgumentParser | ||
|
||
argument_parser = ArgumentParser('Stress Test Plotter') | ||
argument_parser.add_argument("native_logs_path") | ||
arguments = argument_parser.parse_args() | ||
|
||
import matplotlib.pyplot as plt | ||
import pandas as pd | ||
import seaborn as sns | ||
|
||
dataset = pd.read_json(arguments.native_logs_path, lines=True, typ="series") | ||
|
||
def canonicalize_compilation_time(event): | ||
# keep contract compilation finished logs | ||
if "contract compilation finished" not in event["fields"]["message"]: | ||
return None | ||
|
||
compilation_span = find_span(event, "contract compilation") | ||
if compilation_span is None: | ||
return None | ||
|
||
return { | ||
"class hash": compilation_span["class_hash"], | ||
"time": float(event["fields"]["time"]), | ||
} | ||
|
||
def find_span(event, name): | ||
for span in event["spans"]: | ||
if name in span["name"]: | ||
return span | ||
return None | ||
|
||
def format_hash(class_hash): | ||
return f"0x{class_hash[:6]}..." | ||
|
||
dataset = dataset.apply(canonicalize_compilation_time).dropna().apply(pd.Series) | ||
|
||
figure, ax = plt.subplots() | ||
|
||
sns.set_color_codes("bright") | ||
sns.barplot(ax=ax, y="class hash", x="time", data=dataset, formatter=format_hash) # type: ignore | ||
|
||
ax.set_xlabel("Compilation Time (ms)") | ||
ax.set_ylabel("Class Hash") | ||
ax.set_title("Native Compilation Time") | ||
|
||
plt.show() |
Oops, something went wrong.