| 1 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
// Bench script of Cache_Lite_Function
|
|
|
4 |
// $Id: bench3.php 202006 2005-12-04 16:03:55Z fab $
|
|
|
5 |
|
|
|
6 |
require_once('Cache/Lite/Function.php');
|
|
|
7 |
|
|
|
8 |
$options = array(
|
|
|
9 |
'caching' => true,
|
|
|
10 |
'cacheDir' => '/tmp/',
|
|
|
11 |
'lifeTime' => 10
|
|
|
12 |
);
|
|
|
13 |
|
|
|
14 |
$cache = new Cache_Lite_Function($options);
|
|
|
15 |
|
|
|
16 |
$data = $cache->call('function_to_bench', 23, 66);
|
|
|
17 |
echo($data);
|
|
|
18 |
|
|
|
19 |
$object = new bench();
|
|
|
20 |
$object->test = 666;
|
|
|
21 |
$data = $cache->call('object->method_to_bench', 23, 66);
|
|
|
22 |
echo($data);
|
|
|
23 |
|
|
|
24 |
$data = $cache->call('bench::static_method_to_bench', 23, 66);
|
|
|
25 |
echo($data);
|
|
|
26 |
|
|
|
27 |
function function_to_bench($arg1, $arg2)
|
|
|
28 |
{
|
|
|
29 |
for($i=0;$i<10000;$i++) {
|
|
|
30 |
$tmp = md5(md5(md5('Loosing time...')));
|
|
|
31 |
}
|
|
|
32 |
echo "This is the output of the function function_to_bench($arg1, $arg2) !<br>";
|
|
|
33 |
return "This is the result of the function function_to_bench($arg1, $arg2) !<br>";
|
|
|
34 |
}
|
|
|
35 |
|
|
|
36 |
class bench
|
|
|
37 |
{
|
|
|
38 |
var $test;
|
|
|
39 |
|
|
|
40 |
function method_to_bench($arg1, $arg2)
|
|
|
41 |
{
|
|
|
42 |
for($i=0;$i<10000;$i++) {
|
|
|
43 |
$tmp = md5(md5(md5('Loosing time...')));
|
|
|
44 |
}
|
|
|
45 |
echo "\$obj->test = $this->test and this is the output of the method \$obj->method_to_bench($arg1, $arg2) !<br>";
|
|
|
46 |
return "\$obj->test = $this->test and this is the result of the method \$obj->method_to_bench($arg1, $arg2) !<br>";
|
|
|
47 |
}
|
|
|
48 |
|
|
|
49 |
function static_method_to_bench($arg1, $arg2)
|
|
|
50 |
{
|
|
|
51 |
for($i=0;$i<10000;$i++) {
|
|
|
52 |
$tmp = md5(md5(md5('Loosing time...')));
|
|
|
53 |
}
|
|
|
54 |
echo "This is the output of the function static_method_to_bench($arg1, $arg2) !<br>";
|
|
|
55 |
return "This is the result of the function static_method_to_bench($arg1, $arg2) !<br>";
|
|
|
56 |
}
|
|
|
57 |
|
|
|
58 |
}
|
|
|
59 |
|
|
|
60 |
?>
|