In [1]:
%matplotlib inline
In [2]:
from __future__ import print_function
from ipywidgets import interact
In [3]:
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
In [4]:
from collections import defaultdict
from proxenos.node import SocketAddress
from proxenos.rendezvous import select_node
In [5]:
cluster = set()
for i in range(10):
cluster.add(SocketAddress('192.168.100.{}'.format(100 + i), 8000))
In [6]:
def plt_distribution(n=1000):
dist = defaultdict(int)
for i in xrange(n):
node = select_node(cluster, str(i))
dist[str(node.host)] += 1
x, y = zip(*dist.items())
ax = plt.subplot()
ax.bar(range(len(x)), y)
ax.set_xticklabels(x, rotation=90)
ax.set_xticks(np.arange(len(x)))
plt.show()
In [7]:
interact(plt_distribution, n=(100, 10000));