Search in sources :

Example 1 with PolicyStats

use of com.github.benmanes.caffeine.cache.simulator.policy.PolicyStats in project caffeine by ben-manes.

the class CsvReporter method assemble.

@Override
protected String assemble(List<PolicyStats> results) {
    StringWriter output = new StringWriter();
    CsvWriter writer = new CsvWriter(output, new CsvWriterSettings());
    writer.writeHeaders(headers());
    for (PolicyStats policyStats : results) {
        Object[] data = new Object[] { policyStats.name(), String.format("%.2f", 100 * policyStats.hitRate()), policyStats.hitCount(), policyStats.missCount(), policyStats.requestCount(), policyStats.evictionCount(), String.format("%.2f", 100 * policyStats.admissionRate()), (policyStats.operationCount() == 0) ? null : policyStats.operationCount(), policyStats.stopwatch().elapsed(TimeUnit.MILLISECONDS) };
        writer.writeRow(data);
    }
    writer.close();
    return output.toString();
}
Also used : StringWriter(java.io.StringWriter) CsvWriter(com.univocity.parsers.csv.CsvWriter) PolicyStats(com.github.benmanes.caffeine.cache.simulator.policy.PolicyStats) CsvWriterSettings(com.univocity.parsers.csv.CsvWriterSettings)

Example 2 with PolicyStats

use of com.github.benmanes.caffeine.cache.simulator.policy.PolicyStats in project caffeine by ben-manes.

the class TableReporter method assemble.

/** Assembles an aggregated report. */
@Override
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
protected String assemble(List<PolicyStats> results) {
    String[][] data = new String[results.size()][headers().length];
    for (int i = 0; i < results.size(); i++) {
        PolicyStats policyStats = results.get(i);
        data[i] = new String[] { policyStats.name(), String.format("%.2f %%", 100 * policyStats.hitRate()), String.format("%,d", policyStats.hitCount()), String.format("%,d", policyStats.missCount()), String.format("%,d", policyStats.requestCount()), String.format("%,d", policyStats.evictionCount()), String.format("%.2f %%", 100 * policyStats.admissionRate()), steps(policyStats), policyStats.stopwatch().toString() };
    }
    return FlipTable.of(headers(), data);
}
Also used : PolicyStats(com.github.benmanes.caffeine.cache.simulator.policy.PolicyStats)

Aggregations

PolicyStats (com.github.benmanes.caffeine.cache.simulator.policy.PolicyStats)2 CsvWriter (com.univocity.parsers.csv.CsvWriter)1 CsvWriterSettings (com.univocity.parsers.csv.CsvWriterSettings)1 StringWriter (java.io.StringWriter)1