<commit_before>const browser = typeof window === 'object';

function noop () {
  // poop
}

function hrtime () {
  return browser ? performance.now() : new Date().getTime();
}

module.exports = function (func, opts = {}) {
  let elapsed = 0
  let runs = 0;
  
  after = opts.after || noop;
  before = opts.before || noop;
  time = opts.time || 1000;
  
  while (elapsed < time) {
    const arg = before() || [];
    const now = hrtime();
    func.apply(null, arg);
    elapsed += hrtime() - now;
    after();
    ++runs;
  }
  
  return Promise.resolve(runs / (time / 1000));
};<commit_msg>fix: fix undefined errors that weren't happening in node for some reason<commit_after>const browser = typeof window === 'object';

function noop () {
  // poop
}

function hrtime () {
  return browser ? performance.now() : new Date().getTime();
}

module.exports = function (func, opts = {}) {
  let elapsed = 0
  let runs = 0;
  
  const after = opts.after || noop;
  const before = opts.before || noop;
  const time = opts.time || 1000;
  
  while (elapsed < time) {
    const arg = before() || [];
    const now = hrtime();
    func.apply(null, arg);
    elapsed += hrtime() - now;
    after();
    ++runs;
  }
  
  return Promise.resolve(runs / (time / 1000));
};
{'fraction_non_alphanumeric': 0.16388225934765313, 'fraction_numerical': 0.015910898965791568, 'mean_word_length': 2.82370820668693, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '1383065', 'n_tokens_mistral': 438, 'n_tokens_neox': 422, 'n_words': 122}