<commit_before><commit_msg>Expose CPU related metrics from page.metrics()<commit_after>/**
 * Retrieves stats about layouts, style recalcs and JS execution
 *
 * Metrics from https://github.com/puppeteer/puppeteer/blob/main/docs/api.md#pagemetrics
 */
"use strict";

module.exports = function (phantomas) {

  phantomas.on("metrics", (metrics) => {
    phantomas.setMetric("layoutCount", metrics.LayoutCount); // @desc total number of full or partial page layout
    phantomas.setMetric("layoutDuration", metrics.LayoutDuration); // @desc combined durations in seconds of all page layouts
    phantomas.setMetric("recalcStyleCount", metrics.RecalcStyleCount); // @desc total number of page style recalculations
    phantomas.setMetric("recalcStyleDuration", metrics.RecalcStyleDuration); // @desc combined duration in seconds of all page style recalculations
    phantomas.setMetric("scriptDuration", metrics.ScriptDuration); // @desc combined duration in seconds of JavaScript execution
    phantomas.setMetric("taskDuration", metrics.TaskDuration); // @desc combined duration in seconds of all tasks performed by the browser
  });
};

{'fraction_non_alphanumeric': 0.10475352112676056, 'fraction_numerical': 0.0, 'mean_word_length': 5.247252747252747, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '215446', 'n_tokens_mistral': 308, 'n_tokens_neox': 291, 'n_words': 92}