<s> from django . test . client import Client , FakePayload <EOL> from django . conf import global_settings <EOL> from django . conf import settings <EOL> from django . core . handlers . wsgi import WSGIRequest <EOL> from django . core . handlers . wsgi import WSGIHandler <EOL> from djangobench . utils import run_comparison_benchmark <EOL> class RequestFactory ( Client ) : <EOL> """<STR_LIT>""" <EOL> def request ( self , ** request ) : <EOL> """<STR_LIT>""" <EOL> environ = { <EOL> '<STR_LIT>' : self . cookies . output ( header = '<STR_LIT>' , sep = '<STR_LIT>' ) , <EOL> '<STR_LIT>' : '<STR_LIT:/>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:GET>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : FakePayload ( '<STR_LIT>' ) , <EOL> } <EOL> environ . update ( self . defaults ) <EOL> environ . update ( request ) <EOL> return WSGIRequest ( environ ) <EOL> def setup ( ) : <EOL> global req_factory , handler_default_middleware , handler_no_middleware <EOL> req_factory = RequestFactory ( ) <EOL> settings . MIDDLEWARE_CLASSES = global_settings . MIDDLEWARE_CLASSES <EOL> handler_default_middleware = WSGIHandler ( ) <EOL> handler_default_middleware . load_middleware ( ) <EOL> settings . MIDDLEWARE_CLASSES = [ ] <EOL> handler_no_middleware = WSGIHandler ( ) <EOL> handler_no_middleware . load_middleware ( ) <EOL> def benchmark_request ( middleware_classes ) : <EOL> settings . MIDDLEWARE_CLASSES = middleware_classes <EOL> req_factory = RequestFactory ( ) <EOL> handler = WSGIHandler ( ) <EOL> handler . load_middleware ( ) <EOL> handler . get_response ( req_factory . get ( '<STR_LIT:/>' ) ) <EOL> def benchmark_default_middleware ( ) : <EOL> global req_factory , handler_default_middleware <EOL> handler_default_middleware . get_response ( req_factory . get ( '<STR_LIT:/>' ) ) <EOL> def benchmark_no_middleware ( ) : <EOL> global req_factory , handler_no_middleware <EOL> handler_no_middleware . get_response ( req_factory . get ( '<STR_LIT:/>' ) ) <EOL> run_comparison_benchmark ( <EOL> benchmark_default_middleware , <EOL> benchmark_no_middleware , <EOL> setup = setup , <EOL> migrate = False , <EOL> meta = { <EOL> '<STR_LIT:description>' : '<STR_LIT>' , <EOL> } <EOL> ) </s>
