Sign up ×
Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.

I am using Apache ab to test one simple file and Zend application.

Zend application page is default page that comes with skeleton application.

And another file is show below:

$start = -microtime(TRUE);
ini_set("max_execution_time", 0);
date_default_timezone_set("Asia/Kolkata");
echo "<pre>";

//echo date("d-M-Y H:i", 1392034673).PHP_EOL;
//echo date("d-M-Y H:i", 1391771666).PHP_EOL;

$string = "abc/{name}/{name}/{message}";

preg_match_all('#{.*}#', $string, $match);

var_dump($match);

echo $url = preg_replace(array('#{name}#', '#{message}#'), array('([a-zA-Z]+)', '([a-zA-Z0-9_-]+)'), str_replace("/", "\\/", $string));
preg_match('#' . $url . '#', "abc/hi/hi/bhavik-is-saying", $matched);

var_dump($matched);

echo "<br/>Process time : " . (microtime(TRUE) + $start);

Benchmark Results

ab -n 50 -c 20 http://local.host/zend/public

Time : 24.600 ms

Request per second : 406.50

ab -n 50 -c 20 http://local.host/test/test.php

Time : 52.600 ms

Request per second : 190.11

Why is test.php behind Zend application even though my test.php have less code compared to Zend application?

share|improve this question

closed as off-topic by Bobby, Elias Van Ootegem, Nikita Brizhak, kleinfreund, Uri Agassi Feb 17 '14 at 9:43

If this question can be reworded to fit the rules in the help center, please edit the question.

4  
This question appears to be off-topic because it is about review of code, but why a the Zend framework/server is faster than pure PHP. –  Bobby Feb 17 '14 at 8:08
    
Because Zend was designed to do exactly that, being faster than everything else. –  Bobby Feb 17 '14 at 8:08
    
Because that Zend application is probably being cached quite heavily, and doesn't execute 4 preg_* calls –  Elias Van Ootegem Feb 17 '14 at 8:09
2  
@Bobby: Well that's exactly 100% wrong. Zend, like Symfony aim to be scalable, cachable, testable, modular (not ZF1, but S2 and ZF2), but most importantly: stable. They're developed to be used in large projects. The req/s will be slower than alternatives if you're running a small site, but as it grows, ZF2 and Symfony will keep these req/s numbers ~constant. Other Frameworks might start to slip up –  Elias Van Ootegem Feb 17 '14 at 8:21
1  
@Bobby this is regarding code review because i want to know how can i improve this code so that it can beat zend. so code review is required –  user2907171 Feb 17 '14 at 8:28

Browse other questions tagged or ask your own question.