CHI::Stats(3pm) | User Contributed Perl Documentation | CHI::Stats(3pm) |

# 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, ...);

- enable, disable, enabled
- Enable, disable, and query the current enabled status.
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

- flush
- Log all statistics to Log::Any (at Info level in the
CHI::Stats category), then clear statistics from memory. There is one log
message for each distinct triplet of root class, cache label, and
namespace. Each log message contains the string "CHI stats:"
followed by a JSON encoded hash of statistics. e.g.
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}

- parse_stats_logs
- Accepts one or more stats log files as parameters. Parses
the logs and returns a listref of stats hashes by root class, cache label,
and namespace. e.g.
[ { root_class => 'CHI', label => 'File', namespace => 'Foo', absent_misses => 100, avg_compute_time_ms => 23, ... }, { root_class => 'CHI', label => 'File', namespace => 'Bar', ... }, ]

- •
- "absent_misses" - Number of gets that failed due to item not being in the cache

- •
- "compute_time_ms" - Total time spent computing
missed results in compute, in ms (divide by number of computes to get
average). i.e. the amount of time spent in the code reference passed as
the third argument to
*compute()*.

- •
- "computes" - Number of compute calls

- •
- "expired_misses" - Number of gets that failed due to item expiring

- •
- "get_errors" - Number of caught runtime errors during gets

- •
- "get_time_ms" - Total time spent in get operation, in ms (divide by number of gets to get average)

- •
- "hits" - Number of gets that succeeded

- •
- "set_key_size" - Number of bytes in set keys (divide by number of sets to get average)

- •
- "set_value_size" - Number of bytes in set values (divide by number of sets to get average)

- •
- "set_time_ms" - Total time spent in set operation, in ms (divide by number of sets to get average)

- •
- "sets" - Number of sets

- •
- "set_errors" - Number of caught runtime errors during sets

- •
- "misses" - "absent_misses" + "expired_misses"

- •
- "gets" - "hits" + "misses"

- •
- "avg_compute_time_ms" - "compute_time_ms" / "computes"

- •
- "avg_get_time_ms" - "get_time_ms" / "gets"

- •
- "avg_set_time_ms" - "set_time_ms" / "sets"

- •
- "avg_set_key_size" - "set_key_size" / "sets"

- •
- "avg_set_value_size" - "set_value_size" / "sets"

- •
- "hit_rate" - "hits" / "gets"

2017-07-31 | perl v5.26.0 |