Skip to content

Instantly share code, notes, and snippets.

@r-brink
Created January 4, 2024 10:32
Show Gist options
  • Save r-brink/790ec9cac1cb7ec45b522fd57c49950f to your computer and use it in GitHub Desktop.
Save r-brink/790ec9cac1cb7ec45b522fd57c49950f to your computer and use it in GitHub Desktop.
import numpy as np
import pandas as pd
import polars as pl
import matplotlib.pyplot as plt
def plot_grouped_benchmark_results(results: dict):
libraries = [
f"Polars {pl.__version__}",
f"Pandas {pd.__version__}",
f"NumPy {np.__version__}",
]
operations = ["Corr", "Cov"]
data = {
op: [results[f"{op} with {lib.split()[0]}"] for lib in libraries]
for op in operations
}
x = range(len(operations))
x = range(len(operations))
custom_colors = ['#0075FF', '#73bfb8', '#26413c']
plt.figure(figsize=(10, 6))
for i, library in enumerate(libraries):
plt.bar(
[pos + i * 0.2 for pos in x],
[data[operation][i] for operation in operations],
width=0.15,
label=library,
color=custom_colors[i]
)
plt.xlabel("Operation")
plt.ylabel("Average Time (s)")
plt.title("Benchmarking Results Grouped by Operation")
ax = plt.gca()
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
plt.xticks([pos + 0.2 for pos in x], operations)
plt.legend()
plt.savefig('algorithmic_speedups_results.png')
plt.show()
plot_grouped_benchmark_results(benchmark_results)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment