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

cache = Client(('localhost', 11211))

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

cache.close()
