"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
postscriptum.plugin('ps-performances', (processor) => {
    const { util } = postscriptum;
    const { logger } = util;
    const starts = { process: NaN, preparation: NaN, pagination: NaN, print: NaN };
    const durations = { process: NaN, preparation: NaN, pagination: NaN, print: NaN };
    function formatTime(time) {
        return Math.ceil(time) / 1000 + 's';
    }
    processor
        .on('start', () => {
        starts.process = performance.now();
    })
        .on('end', () => {
        durations.process = performance.now() - starts.process;
        logger.info(`Process: ${formatTime(durations.process)}, preparation: ${formatTime(durations.preparation)}, pagination: ${formatTime(durations.pagination)}`);
    })
        .on('preparation-start', () => {
        starts.preparation = performance.now();
    })
        .on('preparation-end', () => {
        durations.preparation = performance.now() - starts.preparation;
    })
        .on('pagination-start', () => {
        starts.pagination = performance.now();
    })
        .on('pagination-end', () => {
        durations.pagination = performance.now() - starts.pagination;
    })
        .on('print-start', () => {
        starts.print = performance.now();
    })
        .on('print-end', () => {
        durations.print = performance.now() - starts.print;
        logger.info(`Print: ${formatTime(durations.print)}`);
    });
});
