Skip to content

Instantly share code, notes, and snippets.

@tomislater
Created September 28, 2013 17:35
Show Gist options
  • Select an option

  • Save tomislater/6744440 to your computer and use it in GitHub Desktop.

Select an option

Save tomislater/6744440 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import timeit
from memcache import Client
from multiprocessing import Process
def worker(x, y):
mc = Client(['127.0.0.1:11211'], debug=0)
for s in (str(i) for i in xrange(x, y)):
mc.set(s, s.capitalize())
mc.get(s)
mc.incr(s, 1)
mc.decr(s, 1)
def test():
process = []
for x, y in ((0, 250), (250, 500), (500, 750), (750, 1000)):
p = Process(target=worker, args=(x, y,))
p.start()
process.append(p)
for p in process:
p.join()
t = 0
for _ in xrange(3):
t += timeit.timeit(test, number=100)
print t / 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment