``````

In [ ]:

# This script tries to model the cost of siphash
import pandas as pd
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import axes3d
import math
from scipy import optimize
import numpy as np

figsize=(4.5, 3)

``````
``````

In [ ]:

``````
``````

In [ ]:

# The siphash model
def fitfunc(x,t,o):
# Actual mathematical model
def runner(a):
return (t/a) + o
# Magic for scipy
if isinstance(x, np.ndarray):
ret = []
for s in x:
ret += [runner(s)]
return ret
else:
return runner(x)

#params = [1.02,2**11,600]
# Fit the data
params, _ = optimize.curve_fit(fitfunc, data['size'], data['cycles'])

print(params)

# Plot the data
fit = []
for s in data['size']:
fit += [fitfunc(s,params[0],params[1])]

fig = plt.figure(figsize=figsize, dpi=300)
plt.scatter(data['size'], data['cycles'], 5, label="data")
plt.plot(data['size'], fit, color='orange', label="fit")
plt.ylim([1,2**10])
#plt.semilogx(basex=2)
plt.loglog(basex=2, basey=2)
plt.grid(b=True)
plt.xlabel('#Runs')
plt.ylabel('Cycles per Run')
plt.legend()
fig.savefig('output/synth-siphash.pdf',bbox_inches='tight')
plt.show()

``````
``````

In [ ]:

``````