``````

In [ ]:

# This script tries to approximate the cost of Google's DenseMap

import pandas as pd
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import math
import numpy as np

figsize=(4.5, 3)

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

In [ ]:

# Just plot the data
setupMin = data.groupby(['size'])['setup'].min()
runMin = data.groupby(['size'])['run'].min()
steps = data['size'].unique()

plt.semilogx(basex=2)
plt.ylim([0,1200])

plt.plot(steps, setupMin)

plt.grid(b=True)

plt.show()

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

In [ ]:

# This function models the insertion cost
def fun(x):
return (600 + math.log(x,1.2)) + 150* (((np.sum([2**i for i in range(2, math.floor(math.log(x,2)))])/ x) -0.5) *2)

# This function models the query cost
def fun2(x):
return math.log(x,1.06)

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

In [ ]:

#x = np.arange(2**10-1,2**17, 16)
# Calculate the functions
y = [fun(i) for i in steps]
y2 = [fun2(i) for i in steps]

fig = plt.figure(figsize=figsize, dpi=300)

plt.semilogx(basex=2)
plt.ylim([0,1200])

# Plot the data
plt.plot(steps,y, label="fit-setup")
plt.plot(steps, setupMin, label="data-setup")
plt.plot(steps, y2, label="fit-run")
plt.plot(steps, runMin, label="data-run")
plt.legend(bbox_to_anchor=(1, 1))
plt.ylabel("Cycles per Operation")
plt.xlabel("#Operations")
plt.grid(b=True)

plt.savefig('output/synth-denseMap.pdf',bbox_inches='tight')
plt.show()

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

In [ ]:

``````