<commit_before>/**
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @flow
 * @format
 */

'use strict';

const chalk = require('chalk');

import type {GraphQLReporter} from './GraphQLReporter';

function getMemoryUsageString() {
  return chalk.blue(
    Math.round(process.memoryUsage().heapUsed / 1024 / 1024) + 'Mb',
  );
}

class GraphQLConsoleReporter implements GraphQLReporter {
  _verbose: boolean;
  _quiet: boolean;

  constructor(options: {verbose: boolean, quiet: boolean}) {
    this._verbose = options.verbose;
    this._quiet = options.quiet;
  }

  reportMessage(message: string): void {
    if (!this._quiet) {
      process.stdout.write(message + '\n');
    }
  }

  reportTime(name: string, ms: number): void {
    /* $FlowFixMe(>=0.68.0 site=react_native_fb,react_native_oss) This comment
     * suppresses an error found when Flow v0.68 was deployed. To see the error
     * delete this comment and run Flow. */
    if (this._verbose && !this.quiet) {
      const time =
        ms === 0
          ? chalk.gray(' <1ms')
          : ms < 1000
          ? chalk.blue(leftPad(5, ms + 'ms'))
          : chalk.red(Math.floor(ms / 10) / 100 + 's');
      process.stdout.write(
        '  ' +<commit_msg>fix flow issue in ConsoleReporter<commit_after>/**
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @flow
 * @format
 */

'use strict';

const chalk = require('chalk');

import type {GraphQLReporter} from './GraphQLReporter';

function getMemoryUsageString() {
  return chalk.blue(
    Math.round(process.memoryUsage().heapUsed / 1024 / 1024) + 'Mb',
  );
}

class GraphQLConsoleReporter implements GraphQLReporter {
  _verbose: boolean;
  _quiet: boolean;

  constructor(options: {verbose: boolean, quiet: boolean}) {
    this._verbose = options.verbose;
    this._quiet = options.quiet;
  }

  reportMessage(message: string): void {
    if (!this._quiet) {
      process.stdout.write(message + '\n');
    }
  }

  reportTime(name: string, ms: number): void {
    if (this._verbose && !this._quiet) {
      const time =
        ms === 0
          ? chalk.gray(' <1ms')
          : ms < 1000
          ? chalk.blue(leftPad(5, ms + 'ms'))
          : chalk.red(Math.floor(ms / 10) / 100 + 's');
      process.stdout.write(
        '  ' +
{'fraction_non_alphanumeric': 0.13438735177865613, 'fraction_numerical': 0.01857707509881423, 'mean_word_length': 2.840667678300455, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5323329', 'n_tokens_mistral': 843, 'n_tokens_neox': 775, 'n_words': 223}