Re: Cache_Lite 1.0 ?
| From: | Fabien MARTY | Date: | Thu, 07 Nov 2002 08:06:17 +0000 |
| Subject: | Re: Cache_Lite 1.0 ? | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-10526@lists.php.net to get a copy of this message | ||
> Fabien,
> Can you provide a benchmarking test case to help identify the speed
> differences between Cache and Cache_Lite?
In the tests/ subdirectory (of the package), there is a file 'readme' which
describes a way to bench. It the tests/ subdirectory, there are some files
to bench (bench.php bench the core class)
----------------------------------------------------------------------------
-
To bench Cache_Lite, I use the tool 'ab' (distributed with apache).
(for example)
/usr/sbin/ab -c 10 -n 1000 http://127.0.0.1/ [...]
/Cache_Lite/tests/bench.php
In the output of 'ab', most important things are :
- Failed requests: (must be 0 ! If not, don't commit !)
- Requests per second: XXX [#/sec] (mean)
For testing if the cache is ok or not, you can use the script 'test.php', it
will write if the cache has been hit or missed...
----------------------------------------------------------------------------
--
Here is the bench.php file (10 s lifetime cache) :
----------------------------------------------------------------------------
--
require_once('Cache/Lite.php');
$options = array(
'caching' => true,
'cacheDir' => '/tmp/',
'lifeTime' => 10
);
$Cache_Lite = new Cache_Lite($options);
if ($data = $Cache_Lite->get('123')) {
echo($data);
} else {
$data = '';
for($i=0;$i<1000;$i++) {
$data .= '0123456789';
}
echo($data);
$Cache_Lite->save($data);
}
?>
----------------------------------------------------------------------------
--
If I transpose the file for Cache, it should be (not tested) :
----------------------------------------------------------------------------
--
require_once('Cache/Cache.php');
$options = array(
'cache_dir' => '/tmp/',
);
$lifeTime=10
$Cache = new Cache('file', $options);
if ($data = $Cache->get('123')) {
echo($data);
} else {
$data = '';
for($i=0;$i<1000;$i++) {
$data .= '0123456789';
}
echo($data);
$Cache->save('123', $data, $lifeTime);
}
?>
----------------------------------------------------------------------------
--
I'm sorry but I have no web server here to play with. So I can't test these
scripts for you.
Fab