| 1 |
# This script plot the result generated by profile_factorization.rs |
| 2 |
from re import A |
| 3 |
import pandas as pd |
| 4 |
import numpy as np |
| 5 |
from matplotlib import pyplot as plt |
| 6 |
|
| 7 |
def plot_n_stats(): |
| 8 |
table = pd.read_csv("profile_stats.csv") |
| 9 |
table.drop(columns=["n"], inplace=True) |
| 10 |
pollard_cols = list(k for k in table.columns if k.startswith("pollard")) |
| 11 |
squfof_cols = list(k for k in table.columns if k.startswith("squfof")) |
| 12 |
oneline_cols = list(k for k in table.columns if k.startswith("one_line")) |
| 13 |
|
| 14 |
# MAXITER = 1 << 20 |
| 15 |
# table[table >= MAXITER] = np.nan |
| 16 |
|
| 17 |
mean_table = table.groupby(table['n_bits'] // 4).agg(np.nanmean) |
| 18 |
fig, ax = plt.subplots() |
| 19 |
mean_table.plot("n_bits", pollard_cols, ax=ax) |
| 20 |
mean_table.plot("n_bits", squfof_cols, ax=ax) |
| 21 |
mean_table.plot("n_bits", oneline_cols, ax=ax) |
| 22 |
ax.set_yscale("log") |
| 23 |
|
| 24 |
min_table = table.groupby(table['n_bits'] // 4).agg(np.nanmin) |
| 25 |
fig, ax = plt.subplots() |
| 26 |
ax.plot(min_table["n_bits"], np.mean(min_table[pollard_cols], axis=1), label="pollard") |
| 27 |
ax.plot(min_table["n_bits"], np.mean(min_table[squfof_cols], axis=1), label="squfof") |
| 28 |
ax.plot(min_table["n_bits"], np.mean(min_table[oneline_cols], axis=1), label="one_line") |
| 29 |
ax.legend() |
| 30 |
ax.set_yscale("log") |
| 31 |
|
| 32 |
def plot_n_min_stats(): |
| 33 |
table = pd.read_csv("profile_stats.csv") |
| 34 |
table.drop(columns=["n"], inplace=True) |
| 35 |
for k in table.columns: # caculate average time |
| 36 |
if k.startswith("time_"): |
| 37 |
table[k] = table[k] / table[k[5:]] |
| 38 |
print(table[k]) |
| 39 |
min_table = table.groupby(table['n_bits'] // 4).agg(np.nanmean) |
| 40 |
|
| 41 |
# MAXITER = 1 << 24 |
| 42 |
# table[table >= MAXITER] = np.nan |
| 43 |
|
| 44 |
ax = min_table.plot("n_bits", ["pollard_rho", "squfof", "one_line"]) |
| 45 |
ax.set_yscale("log") |
| 46 |
ax.set_ylabel("min iters") |
| 47 |
|
| 48 |
ax = min_table.plot("n_bits", ["time_pollard_rho", "time_squfof", "time_one_line"]) |
| 49 |
ax.set_yscale("log") |
| 50 |
ax.set_ylabel("avg time per iter") |
| 51 |
|
| 52 |
if __name__ == "__main__": |
| 53 |
# plot_n_stats() |
| 54 |
plot_n_min_stats() |
| 55 |
plt.show() |