コード例 #1
0
    # 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.',
    })
コード例 #2
0
ファイル: benchmark.py プロジェクト: DjangoBD/djangobench
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.',
    }
)
コード例 #3
0
    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.',
    })
コード例 #4
0
ファイル: benchmark.py プロジェクト: Bouke/djangobench
    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.',
    }
)