Exemple #1
0
const char *
Statistics::formatData()
{
    buffer[0] = 0x00;

    int64_t total = 0, longest = 0;

    for (SliceData *slice = slices.begin(); slice != slices.end(); slice++) {
        total += slice->duration();
        if (slice->duration() > longest)
            longest = slice->duration();
    }

    double mmu20 = computeMMU(20 * PRMJ_USEC_PER_MSEC);
    double mmu50 = computeMMU(50 * PRMJ_USEC_PER_MSEC);

    fmt("TotalTime: %.1fms, Type: %s", t(total), compartment ? "compartment" : "global");
    fmt(", MMU(20ms): %d%%, MMU(50ms): %d%%", int(mmu20 * 100), int(mmu50 * 100));

    if (slices.length() > 1)
        fmt(", MaxPause: %.1f", t(longest));
    else
        fmt(", Reason: %s", ExplainReason(slices[0].reason));

    if (wasReset)
        fmt(", ***RESET***");

    fmt(", +chunks: %d, -chunks: %d\n", counts[STAT_NEW_CHUNK], counts[STAT_DESTROY_CHUNK]);

    if (slices.length() > 1) {
        for (size_t i = 0; i < slices.length(); i++) {
            int64_t width = slices[i].duration();
            if (i != 0 && i != slices.length() - 1 && width < SLICE_MIN_REPORT_TIME)
                continue;

            fmt("    Slice %d @ %.1fms (Pause: %.1f, Reason: %s): ",
                i,
                t(slices[i].end - slices[0].start),
                t(width),
                ExplainReason(slices[i].reason));
            formatPhases(slices[i].phaseTimes);
            fmt("\n");
        }

        fmt("    Totals: ");
    }

    formatPhases(phaseTimes);
    fmt("\n");

    return buffer;
}
Exemple #2
0
Statistics::~Statistics()
{
    if (fp) {
        if (fullFormat) {
            buffer[0] = 0x00;
            formatPhases(phaseTotals);
            fprintf(fp, "TOTALS\n%s\n\n-------\n", buffer);
        }

        if (fp != stdout && fp != stderr)
            fclose(fp);
    }
}
Exemple #3
0
Statistics::~Statistics()
{
    if (fp) {
        if (fullFormat) {
            StatisticsSerializer ss(StatisticsSerializer::AsText);
            formatPhases(ss, "", phaseTotals);
            char *msg = ss.finishCString();
            if (msg) {
                fprintf(fp, "TOTALS\n%s\n\n-------\n", msg);
                js_free(msg);
            }
        }

        if (fp != stdout && fp != stderr)
            fclose(fp);
    }
}