Development

Changeset 23446

You must first sign up to be able to contribute.

Changeset 23446

Show
Ignore:
Timestamp:
10/29/09 21:56:36 (4 years ago)
Author:
FabianLange
Message:

[routing_performance] added a few more routes and parse/generate requests

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • tools/routing_performance/routing_performance.php

    r23440 r23446  
    1818} 
    1919 
    20 $t->diag('Creating routing yml with 1000 routes'); 
     20$t->diag('Creating routing yml with 1500+ routes'); 
    2121$template = <<<EOT 
    2222moduleA%s: 
    23   url: /symfony/rocks/%s 
    24   param: {module: moduleA, action: index} 
     23  url: /symfony%s/:build/:file 
     24  param: { module: build, action: show} 
     25  requirements: { build: ^\d+$ }  
    2526moduleB%s: 
    2627  url: /symfony/rules/%s 
     
    2829 
    2930EOT; 
     31// I really dont know why this did not work being in one string :) 
     32$template2 = <<<EOT 
     33moduleC%s: 
     34  url: /symfony/rocks/%s/:foo/:bar 
     35  param: {module: moduleC, action: foobar} 
     36 
     37EOT; 
     38 
     39$singleRoutes = <<<EOT 
     40star1: 
     41  url: /star/* 
     42  param: {module: star, action: all} 
     43 
     44EOT; 
    3045$routingConfigYml = ''; 
    3146foreach(range(1, 500) as $num) 
    3247{ 
    33   $routingConfigYml.=sprintf($template, $num, $num, $num, $num); 
     48  $routingConfigYml.=sprintf($template, $num, $num, $num, $num, $num, $num); 
     49  $routingConfigYml.=sprintf($template2, $num, $num); 
    3450} 
    35 file_put_contents('routing.yml',$routingConfigYml); 
     51file_put_contents('routing.yml',$routingConfigYml.'\n'.$singleRoutes); 
    3652 
    3753$t->diag($patch.' Routing - Creating Config'); 
     
    5066$stats->log($t); 
    5167 
    52 $t->diag($patch.' Routing - Searching Route'); 
     68$t->diag($patch.' Routing - Searching Routes 10 times'); 
    5369$stats = new Stats(); 
    54 $info = $routingNew->parse('/symfony/rules/420'); 
     70for ($loop = 0; $loop < 10; $loop++) 
     71{  
     72  $info = $routingNew->parse('/symfony/rules/420'); 
     73  $t->is($info['_sf_route']->getPattern(), '/symfony/rules/420'); 
     74  $info = $routingNew->parse('/symfony345/foo/bar'); 
     75  $t->is($info['_sf_route'], null); 
     76  $info = $routingNew->parse('/symfony345/1234/foo'); 
     77  $t->is($info['_sf_route']->getPattern(), '/symfony345/:build/:file'); 
     78  $info = $routingNew->parse('/star/foo/1/bar/2'); 
     79  $t->is($info['foo'], '1'); 
     80  $t->is($info['bar'], '2'); 
     81
     82$t->diag($patch.' Routing - Generating Routes 20 times'); 
     83for ($loop = 0; $loop < 20; $loop++) 
     84{   
     85  $url = $routingNew->generate('moduleA333', array('build' => 42, 'file' => 'foo')); 
     86  $t->is($url, '/symfony333/42/foo'); 
     87  $url = $routingNew->generate(null , array('foo' => 'cat', 'bar' => 'dog', 'module' => 'moduleC')); 
     88  $t->is($url, '/symfony/rocks/1/cat/dog'); 
     89
     90 
    5591$stats->log($t); 
    56 $t->is($info['_sf_route']->getPattern(), '/symfony/rules/420'); 
    5792 
    5893$t->diag($patch.' Routing - Real World Test - Accumulated data'); 
    5994$realWorldUsage->log($t); 
     95$t->diag(sprintf('file: %.2fkb', filesize($patch.'/routing.php')/1024));