Cache::Benchmark - Tests the quality and speed of a cache module to compare cachemodules and algorithms.
Version 0.011
use Cache::Benchmark(); use Cache::MemoryCache(); use Cache::SizeAwareMemoryCache(); my $cache_1 = new Cache::MemoryCache({ namespace => 'my', default_expires_in => 1, }); my $cache_2 = new Cache::SizeAwareMemoryCache({ namespace => 'my', default_expires_in => 1, max_size => 400, }); my $test = new Cache::Benchmark(); $test->init( access_counter => 10_000 ); $test->run($cache_1); print $test->get_printable_result(); $test->run($cache_2); print $test->get_printable_result();
-
No parameter. You have to "init()" the object
return: __PACKAGE__
parameter: -
Initialises and configures the benchmark-test. Without that, no other method will work. All parameters are optional.
return: BOOLEAN
parameter:
how many cache keys are used
the minimal length of any key in the cache. The standard-keys are integers (from 0 till defined "keys"), if you define some min-length, the keys will be filled with initial zeros until reaching the given length.
how many times will a cache key be get() or set() to the cache-module
what the cache-value should be (can be anything except UNDEF, only to stress the memory usage)
types of test. These can be:
plain
not a real test. This will only call all keys one after another. No random, no peaks.
random
only for access-speed tests. The key is randomly generated. No peaks.
weighted
keys are randomly generated and weighted. Some keys have a high chance of being used, others have less chances
the waiting time between each access in seconds. For example use 0.001 to wait a millisecond between each access.
an own config for the test_type "weighted". It's a simple hashref with the following structure:
$config = { 1.5 => 15, 10 => 10, 35 => 7, 50 => 5, 65 => 3, 85 => 2, 99 => 1, };
Example:
means: the first 1.5% of all keys have a 15 times higher chance to hit
means: from 1.5% till 10% the keys will have a 10 times higher chance...
means: from 10% till 35% ... 7 times higher ... ...etc
the key (percent) can be a FLOAT, value (weight) has to be an INT
sets the list of keys the benchmark-test will use in run(). (an ARRAYREF of INT) Usable to repeat exactly the same test which was stored via "get_generated_keylist()" or to define your own list. If you give an access list, all other parameters, except "sleep_time", are senseless.
Attention: the arrayref is not dereferenced!
Runs the benchmark-test with the given cache-object.
every cache-object with an interface like the "Cache" Module. Only the following part of the interface is needed:
sets a cache
reads a cache
cleans up all overhanging caches (on sized cache modules)
should purge() called after any set() or get()? Useful for some SizeAware... Cache modules.
get the list of all accessed keys, which the benchmark-test will set() / get(). Usable to store this list and repeat the test with exactly the same environment.
return: ARRAYREF of INT
returns all benchmark-data in a plain hash for further usage. Have a look at some "get_printable_result()" to understand the data.
return: HASHREF
returns all benchmark-data as a readable string. Quality (cached access divided by uncached access) and runtime (for all get() / set() / purge() operations) are the most important results to compare caches.
return: STRING
Tobias Tacke, <cpan at tobias-tacke.de>
<cpan at tobias-tacke.de>
Please report any bugs or feature requests to bug-cache-benchmark at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Cache-Benchmark. I will be notified, and then you'll automatically be notified of any progress on your bug as I make changes.
bug-cache-benchmark at rt.cpan.org
You can find the documentation of this module with the perldoc command.
perldoc Cache::Benchmark
You can also look for information at:
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Cache-Benchmark
CPAN Ratings
http://cpanratings.perl.org/d/Cache-Benchmark
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Cache-Benchmark
Search CPAN
http://search.cpan.org/dist/Cache-Benchmark
Copyright 2007 Tobias Tacke, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Cache::Benchmark, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Cache::Benchmark
CPAN shell
perl -MCPAN -e shell install Cache::Benchmark
For more information on module installation, please visit the detailed CPAN module installation guide.