Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
--TEST--
2
Cache_Lite::Cache_Lite_Function (classical)
3
--FILE--
4
<?php
5
 
6
require_once('callcache.inc');
7
require_once('tmpdir.inc');
8
require_once('cache_lite_function_base.inc');
9
 
10
$options = array(
11
    'cacheDir' => tmpDir() . '/',
12
    'lifeTime' => 60
13
);
14
 
15
$cache = new Cache_Lite_Function($options);
16
 
17
$data = $cache->call('function_to_bench', 23, 66);
18
echo($data);
19
$data = $cache->call('function_to_bench', 23, 66);
20
echo($data);
21
$cache->call('function_to_bench', 23, 66);
22
 
23
$object = new bench();
24
$object->test = 666;
25
$data = $cache->call('object->method_to_bench', 23, 66);
26
echo($data);
27
$data = $cache->call('object->method_to_bench', 23, 66);
28
echo($data);
29
$cache->call('object->method_to_bench', 23, 66);
30
 
31
$data = $cache->call('bench::static_method_to_bench', 23, 66);
32
echo($data);
33
$data = $cache->call('bench::static_method_to_bench', 23, 66);
34
echo($data);
35
$cache->call('bench::static_method_to_bench', 23, 66);
36
 
37
$object = new test($options);
38
 
39
$cache->clean();
40
 
41
function function_to_bench($arg1, $arg2)
42
{
43
    echo "This is the output of the function function_to_bench($arg1, $arg2) !\n";
44
    return "This is the result of the function function_to_bench($arg1, $arg2) !\n";
45
}
46
 
47
class bench
48
{
49
    var $test;
50
 
51
    function method_to_bench($arg1, $arg2)
52
    {
53
        echo "\$obj->test = $this->test and this is the output of the method \$obj->method_to_bench($arg1, $arg2) !\n";
54
        return "\$obj->test = $this->test and this is the result of the method \$obj->method_to_bench($arg1, $arg2) !\n";
55
    }
56
 
57
    function static_method_to_bench($arg1, $arg2) {
58
        echo "This is the output of the function static_method_to_bench($arg1, $arg2) !\n";
59
        return "This is the result of the function static_method_to_bench($arg1, $arg2) !\n";
60
    }
61
 
62
}
63
 
64
class test
65
{
66
    function test($options) {
67
        $this->foo = 'bar';
68
        $cache = new Cache_Lite_Function($options);
69
        echo($cache->call(array($this, 'method_to_bench'), 'foo', 'bar'));
70
    }
71
 
72
    function method_to_bench($arg1, $arg2)
73
    {
74
        echo "output : *** $arg1 *** $arg2 *** " . $this->foo . " ***\n";
75
        return "result : *** $arg1 *** $arg2 *** " . $this->foo . " ***\n";
76
    }
77
}
78
 
79
?>
80
--GET--
81
--POST--
82
--EXPECT--
83
This is the output of the function function_to_bench(23, 66) !
84
This is the result of the function function_to_bench(23, 66) !
85
This is the output of the function function_to_bench(23, 66) !
86
This is the result of the function function_to_bench(23, 66) !
87
This is the output of the function function_to_bench(23, 66) !
88
$obj->test = 666 and this is the output of the method $obj->method_to_bench(23, 66) !
89
$obj->test = 666 and this is the result of the method $obj->method_to_bench(23, 66) !
90
$obj->test = 666 and this is the output of the method $obj->method_to_bench(23, 66) !
91
$obj->test = 666 and this is the result of the method $obj->method_to_bench(23, 66) !
92
$obj->test = 666 and this is the output of the method $obj->method_to_bench(23, 66) !
93
This is the output of the function static_method_to_bench(23, 66) !
94
This is the result of the function static_method_to_bench(23, 66) !
95
This is the output of the function static_method_to_bench(23, 66) !
96
This is the result of the function static_method_to_bench(23, 66) !
97
This is the output of the function static_method_to_bench(23, 66) !
98
output : *** foo *** bar *** bar ***
99
result : *** foo *** bar *** bar ***