CHI::Stats(3pm) | User Contributed Perl Documentation | CHI::Stats(3pm) |
CHI::Stats - Record and report per-namespace cache statistics
version 0.60
# Turn on statistics collection CHI->stats->enable(); # Perform cache operations # Flush statistics to logs CHI->stats->flush(); ... # Parse logged statistics my $results = CHI->stats->parse_stats_logs($file1, ...);
CHI can record statistics, such as number of hits, misses and sets, on a per-namespace basis and log the results to your Log::Any logger. You can then parse the logs to get a combined summary.
A single CHI::Stats object is maintained for each CHI root class, and tallies statistics over any number of CHI::Driver objects.
Statistics are reported when you call the "flush" method. You can choose to do this once at process end, or on a periodic basis.
When stats are enabled, each new cache object will collect statistics. Enabling and disabling does not affect existing cache objects. e.g.
my $cache1 = CHI->new(...); CHI->stats->enable(); # $cache1 will not collect statistics my $cache2 = CHI->new(...); CHI->stats->disable(); # $cache2 will continue to collect statistics
CHI stats: {"absent_misses":1,"label":"File","end_time":1338410398, "get_time_ms":5,"namespace":"Foo","root_class":"CHI", "set_key_size":6,"set_time_ms":23,"set_value_size":20,"sets":1, "start_time":1338409391}
[ { root_class => 'CHI', label => 'File', namespace => 'Foo', absent_misses => 100, avg_compute_time_ms => 23, ... }, { root_class => 'CHI', label => 'File', namespace => 'Bar', ... }, ]
Lines with the same root class, cache label, and namespace are summed together. Non-stats lines are ignored. The parser will ignore anything on the line before the "CHI stats:" string, e.g. a timestamp.
Each parameter to this method may be a filename or a reference to an open filehandle.
The following statistics are tracked in the logs:
The following additional derived/aggregate statistics are computed by parse_stats_logs:
CHI
Jonathan Swartz <swartz@pobox.com>
This software is copyright (c) 2012 by Jonathan Swartz.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
2017-07-31 | perl v5.26.0 |