# Path: pyemc/abstractions/test_api.py
# class TestCase(object):
#     def __init__(self, id):
#         self.id = id
# 
#     def set_up(self, client_params):
#         '''Subclasses should implement both set_up and get_client so the runner
#         can get access to the client.'''
#         self.client = client_params.create_client()
# 
#     def get_client(self):
#         return self.client
# 
#     @contextmanager
#     def assert_raises(self, exc_class):
#         raised = False
#         try:
#             yield
# 
#         except exc_class:
#             raised = True
# 
#         if not raised:
#             raise AssertionError("%s not raised" % exc_class.__name__)
# 
#     def write(self, msg):
#         msg = '[test%s] %s' % (self.id, msg)
#         write(msg)


import time
from pyemc.abstractions.test_api import TestCase



class TestStress(TestCase):
    def run_bench(self, func, loops, desc):
        # untimed warmup
        warmup_loops = loops / 3
        for _ in xrange(loops):
            func()

        # timed execution
        start_time = time.time()
        for _ in xrange(loops):
            func()
        end_time = time.time()
        interval = end_time - start_time


# Path: pyemc/abstractions/test_api.py
# class TestCase(object):
#     def __init__(self, id):
#         self.id = id
# 
#     def set_up(self, client_params):
#         '''Subclasses should implement both set_up and get_client so the runner
#         can get access to the client.'''
#         self.client = client_params.create_client()
# 
#     def get_client(self):
#         return self.client
# 
#     @contextmanager
#     def assert_raises(self, exc_class):
#         raised = False
#         try:
#             yield
# 
#         except exc_class:
#             raised = True
# 
#         if not raised:
#             raise AssertionError("%s not raised" % exc_class.__name__)
# 
#     def write(self, msg):
#         msg = '[test%s] %s' % (self.id, msg)
#         write(msg)


# Path: pyemc/test_stress.py
import time
from pyemc.abstractions.test_api import TestCase




class TestStress(TestCase):
    def run_bench(self, func, loops, desc):
        # untimed warmup
        warmup_loops = loops / 3
        for _ in xrange(loops):
            func()

        # timed execution
        start_time = time.time()
        for _ in xrange(loops):
            func()
        end_time = time.time()
        interval = end_time - start_time


        rate = float(loops) / interval