# Instantiate a new dict and call same methods as above - to be fair, # get unlistify in this method where required caseDict = dict(case) caseDict['a'][0] caseDict['b'][1] caseDict['c'][2] caseDict.items() caseDict.values() for i in caseDict: i caseDict.update(update) copy.copy(caseDict) copy.deepcopy(caseDict) caseDict['a'] = ['A'] caseDict['b'] = ['B'] caseDict['c'] = ['C'] run_comparison_benchmark( benchmark_multi, benchmark_dict, migrate=False, meta={ 'description': 'Overhead of a MultiValueDict compared to a builtin dict.', })
def benchmark_dict(): # Instantiate a new dict and call same methods as above - to be fair, # get unlistify in this method where required caseDict = dict(case) caseDict['a'][0] caseDict['b'][1] caseDict['c'][2] caseDict.items() caseDict.values() for i in caseDict: i caseDict.update(update) copy.copy(caseDict) copy.deepcopy(caseDict) caseDict['a'] = ['A'] caseDict['b'] = ['B'] caseDict['c'] = ['C'] run_comparison_benchmark( benchmark_multi, benchmark_dict, migrate = False, meta = { 'description': 'Overhead of a MultiValueDict compared to a builtin dict.', } )
handler_no_middleware.load_middleware() def benchmark_request(middleware_classes): settings.MIDDLEWARE = settings.MIDDLEWARE_CLASSES = middleware_classes req_factory = RequestFactory() handler = WSGIHandler() handler.load_middleware() handler.get_response(req_factory.get('/')) def benchmark_default_middleware(): global req_factory, handler_default_middleware handler_default_middleware.get_response(req_factory.get('/')) def benchmark_no_middleware(): global req_factory, handler_no_middleware handler_no_middleware.get_response(req_factory.get('/')) run_comparison_benchmark( benchmark_default_middleware, benchmark_no_middleware, setup=setup, migrate=False, meta={ 'description': 'Request/response overhead added by the default middleware.', })
handler_default_middleware = WSGIHandler() handler_default_middleware.load_middleware() settings.MIDDLEWARE_CLASSES = [] handler_no_middleware = WSGIHandler() handler_no_middleware.load_middleware() def benchmark_request(middleware_classes): settings.MIDDLEWARE_CLASSES = middleware_classes req_factory = RequestFactory() handler = WSGIHandler() handler.load_middleware() handler.get_response(req_factory.get('/')) def benchmark_default_middleware(): global req_factory, handler_default_middleware handler_default_middleware.get_response(req_factory.get('/')) def benchmark_no_middleware(): global req_factory, handler_no_middleware handler_no_middleware.get_response(req_factory.get('/')) run_comparison_benchmark( benchmark_default_middleware, benchmark_no_middleware, setup = setup, syncdb = False, meta = { 'description': 'Request/response overhead added by the default middleware.', } )