Skip to content

Instantly share code, notes, and snippets.

@dmoa
Created June 22, 2023 13:27
Show Gist options
  • Save dmoa/20cfd10004f28d9bcb6b7f8fd90ff738 to your computer and use it in GitHub Desktop.
Save dmoa/20cfd10004f28d9bcb6b7f8fd90ff738 to your computer and use it in GitHub Desktop.
from memcache import Client
from time import time
n = 100000
def benchtime(fn):
oldtime = time()
fn()
return time() - oldtime
mc = Client(['127.0.0.1:11211'])
@benchtime
def bench():
for i in range(n):
mc.set("%s" % i, i)
num_tests_run = 10
total_value = 0
for i in range(10):
current_value = (float(n) / bench)
total_value += current_value
print("%f queries/second" % (total_value / num_tests_run))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment