<commit_before>"use strict";

const contrib = require("blessed-contrib");
const _ = require("lodash");

class CpuView {

  constructor(options) {

    this.historyDepth = 10;
    this.cpuHistory = _.times(this.historyDepth, _.constant(0));

    this.line = contrib.line({
      label: " cpu utilization ",
      border: {
        type: "line"
      },
      style: {
        line: "yellow",
        text: "green",
        baseline: "black",
        border: {
          fg: "cyan"
        }
      },
      left: "75%",
      height: "33%",
      width: "25%",
      numYLabels: 4,
      maxY: 100,
      showLegend: false,
      wholeNumbersOnly: true
    });

    this.cpuStats = {
      title: "utilization",
      x: _.reverse(_.times(this.historyDepth, String)),
      y: this.cpuHistory
    };

    options.parent.append(this.line);
    this.line.setData(this.cpuStats);
  }

  onEvent(data) {
    this.line.setLabel(` cpu utilization (${data.cpu.utilization}%) `);
    this.cpuHistory.push(data.cpu.utilization);
    if (this.cpuHistory.length > this.historyDepth) {
      this.cpuHistory.shift();
    }

    this.line.setData([this.cpuStats]);
  }
}

module.exports = CpuView;<commit_msg>Round cpu percentage to nearest decimal.<commit_after>"use strict";

const contrib = require("blessed-contrib");
const _ = require("lodash");

class CpuView {

  constructor(options) {

    this.historyDepth = 10;
    this.cpuHistory = _.times(this.historyDepth, _.constant(0));

    this.line = contrib.line({
      label: " cpu utilization ",
      border: {
        type: "line"
      },
      style: {
        line: "yellow",
        text: "green",
        baseline: "black",
        border: {
          fg: "cyan"
        }
      },
      left: "75%",
      height: "33%",
      width: "25%",
      numYLabels: 4,
      maxY: 100,
      showLegend: false,
      wholeNumbersOnly: true
    });

    this.cpuStats = {
      title: "utilization",
      x: _.reverse(_.times(this.historyDepth, String)),
      y: this.cpuHistory
    };

    options.parent.append(this.line);
    this.line.setData(this.cpuStats);
  }

  onEvent(data) {
    this.line.setLabel(` cpu utilization (${data.cpu.utilization.toFixed(1)}%) `);
    this.cpuHistory.push(data.cpu.utilization);
    if (this.cpuHistory.length > this.historyDepth) {
      this.cpuHistory.shift();
    }

    this.line.setData([this.cpuStats]);
  }
}

module.exports = CpuView;
{'fraction_non_alphanumeric': 0.15416323165704865, 'fraction_numerical': 0.011129431162407255, 'mean_word_length': 2.3522099447513813, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, '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': '3475166', 'n_tokens_mistral': 835, 'n_tokens_neox': 787, 'n_words': 144}