[limb-svn] r6790 - misc/template_engines_bench
svn at limb-project.com
svn at limb-project.com
Mon Feb 11 15:18:16 MSK 2008
Author: korchasa
Date: 2008-02-11 15:18:16 +0300 (Mon, 11 Feb 2008)
New Revision: 6790
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6790
Modified:
misc/template_engines_bench/bench.inc.php
misc/template_engines_bench/index.php
Log:
-- small security fix
Modified: misc/template_engines_bench/bench.inc.php
===================================================================
--- misc/template_engines_bench/bench.inc.php 2008-02-11 10:07:21 UTC (rev 6789)
+++ misc/template_engines_bench/bench.inc.php 2008-02-11 12:18:16 UTC (rev 6790)
@@ -1,30 +1,36 @@
<?php
function get_bench_root_url()
{
- $path = explode('?',$_SERVER['REQUEST_URI']);
- return "http://".$_SERVER['HTTP_HOST'].$path[0];
- return 'http://localhost:8080/korchasa-bench/';
+ //$path = explode('?',$_SERVER['REQUEST_URI']);
+ //return "http://".$_SERVER['HTTP_HOST'].$path[0];
+ return 'http://bench.limb-project.com/';
}
-function bench_one($test_name)
+function get_engine_page_url($engine_name)
+{
+ return 'http://localhost:8080/'.$engine_name;
+}
+
+function bench_one($test_name, $iterations, $concurency)
{
- $url = get_bench_root_url().$test_name.'/main.php';
- $ab_str = BENCH_PATH_TO_AB." -dS -n ".BENCH_ITERATIONS." -c ".BENCH_CONCURENCY.' ';
+ $url = get_engine_page_url($test_name).'/main.php';
+ $ab_str = BENCH_PATH_TO_AB." -dS -n ".$iterations." -c ".$concurency.' ';
$sys_str = $ab_str . $url. ' | grep "per second"';
$result_str = exec($sys_str);
$result = explode(':',$result_str);
return (int) $result[1];
}
-function bench_engines($engines)
+function bench_engines($engines, $iterations, $concurency)
{
$results = array();
for($i = 0, $cnt = count($engines); $i < $cnt; $i++)
{
- $result = bench_one($engines[$i]);
+ $result = bench_one($engines[$i], $iterations, $concurency);
$results[$engines[$i]] = $result;
}
arsort($results);
+ log_results($results, $iterations, $concurency);
return $results;
}
@@ -36,6 +42,14 @@
&& '..' != $file
&& ('.' != substr($file, 0, 1));
}
+
+function log_results($engines, $iterations, $concurency)
+{
+ $log_file_path = dirname(__FILE__).'/.bench.log';
+ $fp = fopen($log_file_path, 'a');
+ fwrite($fp, json_encode(array('engines' => $engines, 'iterations' => $iterations, 'concurency' => $concurency))."\n");
+ fclose($fp);
+}
function get_engines()
{
$engines = array();
Modified: misc/template_engines_bench/index.php
===================================================================
--- misc/template_engines_bench/index.php 2008-02-11 10:07:21 UTC (rev 6789)
+++ misc/template_engines_bench/index.php 2008-02-11 12:18:16 UTC (rev 6790)
@@ -263,7 +263,7 @@
if(!isset($_REQUEST['iterations']) || $_REQUEST['iterations'] > BENCH_ITERATIONS_MAX)
$iterations = BENCH_ITERATIONS_DEFAULT;
else
- $iterations = $_REQUEST['iterations'];
+ $iterations = (int) $_REQUEST['iterations'];
$concurency = max($iterations * BENCH_CONCURENCY_FACTOR, BENCH_CONCURENCY_MIN);
More information about the limb-svn
mailing list