# Collection of code snippets by Arne Vajhøj 
# (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
import hazelcast
import time

cfg = hazelcast.ClientConfig()
cli = hazelcast.HazelcastClient(cfg)
cache = cli.get_map("performance_cache")

# put speed
N = 10000
for j in range(5):
    t1 = time.time()
    for i in range(N):
        cache.put("K#" + str(i + 1), i + 1);
    t2 = time.time()
    print("%d puts per second" % (N / (t2 - t1)))

cli.shutdown()
