Development

Changeset 23486

You must first sign up to be able to contribute.

Changeset 23486

Show
Ignore:
Timestamp:
10/31/09 21:54:49 (5 years ago)
Author:
FabianLange
Message:

[routing_performance] introduced cycle parameter to increase the number of calls to routing are made. added loop parameter to route queries to query more different results. added duplicate lookups to take advantage of possible caching.

Files:

Legend:

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

    r23484 r23486  
    11<?php 
    2 // compares the current implementation against a "patched" one 
     2/** 
     3 * compares the performance of the current routing config implementation against a "patched" one 
     4 * params: 
     5 *  - patch directory to use (defaults to 1.3) 
     6 *  - cycles for route manipulation used (defaults to 5 - higher values eliminate inaccuracy of results) 
     7 */ 
     8$patch = isset($argv[1]) ? $argv[1] : '1.3'; 
     9$cycles = isset($argv[2]) ? $argv[2] : 5; 
    310 
    4 // which patch directory to use 
    5 $patch = isset($argv[1]) ? $argv[1] : '1.3'; 
    6  
    7 if (!file_exists($patch)) die ('no patch directory named '.$patch); 
     11if (!is_dir($patch)) die ('no patch directory named '.$patch); 
    812 
    913require_once dirname(__FILE__).'/stats.php'; 
     
    5963file_put_contents('routing.yml', $routingConfigYml.$singleRoutes); 
    6064 
    61 $t->diag($patch.' Routing - Creating Config'); 
     65$t->diag(sprintf('%s Routing - Creating Config', $patch)); 
    6266$stats = new Stats(); 
    6367$routingConfigHandlerNew = new sfRoutingConfigHandlerNew(); 
     
    6872$realWorldUsage = new Stats(); 
    6973 
    70 $t->diag($patch.' Routing - Loading Config'); 
     74$t->diag(sprintf('%s Routing - Loading Config', $patch)); 
    7175$stats = new Stats(); 
    7276$routingNew = new sfPatternRoutingNew(new sfEventDispatcher(), null, array('load_configuration' => true)); 
     
    7478$stats->log($t); 
    7579 
    76 $t->diag($patch.' Routing - Searching Routes 10 times'); 
     80$t->diag(sprintf('%s Routing - Searching and Generating - %s cycles', $patch, $cycles)); 
    7781$stats = new Stats(); 
    78 foreach(range(1, 10) as $loop) 
    79 {  
    80   $info = $routingNew->parse('/symfony/rules/420'); 
    81   $t->is($info['_sf_route']->getPattern(), '/symfony/rules/420'); 
    82   $info = $routingNew->parse('/symfony345/foo/bar'); 
    83   $t->is($info['_sf_route'], null); 
    84   $info = $routingNew->parse('/symfony345/1234/foo'); 
    85   $t->is($info['_sf_route']->getPattern(), '/symfony345/:build/:file'); 
    86   $info = $routingNew->parse('/star/foo/1/bar/2'); 
    87   $t->is($info['foo'], '1'); 
    88   $t->is($info['bar'], '2'); 
     82foreach(range(1, $cycles) as $cycle) 
     83
     84  foreach(range(1, 20) as $loop) 
     85  {  
     86    $info = $routingNew->parse(sprintf('/symfony/rules/4%02s', $loop)); 
     87    $t->is($info['_sf_route']->getPattern(), sprintf('/symfony/rules/4%02s', $loop)); 
     88   
     89    $info = $routingNew->parse('/symfony345/foo/bar'); 
     90    $t->is($info['_sf_route'], null); 
     91     
     92    $info = $routingNew->parse('/symfony345/1234/foo'); 
     93    $t->is($info['_sf_route']->getPattern(), '/symfony345/:build/:file'); 
     94    // same url again to benefit potentially from caching 
     95    $info = $routingNew->parse('/symfony345/1234/foo'); 
     96    $t->is($info['_sf_route']->getPattern(), '/symfony345/:build/:file'); 
     97     
     98    $info = $routingNew->parse(sprintf('/star/foo/%s/bar/2', $loop)); 
     99    $t->is($info['foo'], $loop); 
     100    $t->is($info['bar'], '2'); 
     101   
     102    $url = $routingNew->generate(sprintf('moduleA3%02s', $loop), array('build' => 42, 'file' => 'foo')); 
     103    $t->is($url, sprintf('/symfony3%02s/42/foo', $loop)); 
     104    // same url again to benefit potentially from caching 
     105    $url = $routingNew->generate(sprintf('moduleA3%02s', $loop), array('build' => 42, 'file' => 'foo')); 
     106    $t->is($url, sprintf('/symfony3%02s/42/foo', $loop)); 
     107   
     108    $url = $routingNew->generate(null , array('foo' => 'cat', 'bar' => $loop, 'module' => 'moduleC')); 
     109    $t->is($url, sprintf('/symfony/rocks/1/cat/%s', $loop)); 
     110  } 
    89111} 
    90 $t->diag($patch.' Routing - Generating Routes 20 times'); 
    91 foreach(range(1, 20) as $loop) 
    92  
    93   $url = $routingNew->generate('moduleA333', array('build' => 42, 'file' => 'foo')); 
    94   $t->is($url, '/symfony333/42/foo'); 
    95   $url = $routingNew->generate(null , array('foo' => 'cat', 'bar' => 'dog', 'module' => 'moduleC')); 
    96   $t->is($url, '/symfony/rocks/1/cat/dog'); 
    97 } 
    98  
    99112$stats->log($t); 
    100113