<commit_before>var TIMEOUT = 1000000;

module.exports = function (name, options) {
  describe('', function () {
    var bench;
    var title = this.fullTitle();

    beforeEach(function () {
      options = typeof options === 'function' ? { fn: options } : options;
      options.name = title + name;
      bench = new Benchmark(options);
    });

    it(name, function (done) {
      this.title = options.name;
      this.timeout(TIMEOUT);

      bench.on('complete', function (e) {
        alert(`${String(e.target)}`);
        done();
      });

      bench.run();
    });
  });
};<commit_msg>Add ability to specify an async test the same way you do in Mocha except for the fact that it's a deferred object not a function because we can't change that.<commit_after>var TIMEOUT = 1000000;

function hasArguments (fn) {
  var fnStr = fn.toString();
  return (fnStr.indexOf('(') + 1) < fnStr.indexOf(')');
}

module.exports = function (name, options) {
  describe('', function () {
    var title = this.fullTitle();

    if (typeof options === 'function') {
      options = { fn: options };
    }

    var isAsync = hasArguments(options.fn);

    options.defer = isAsync;
    options.name = title + name;

    var bench = new Benchmark(options);

    it(name, function (done) {
      this.title = options.name;
      this.timeout(TIMEOUT);

      bench.on('complete', function (e) {
        alert(`${String(e.target)}`);
        done();
      });

      bench.run({ async: isAsync });
    });
  });
};
{'fraction_non_alphanumeric': 0.15722851432378415, 'fraction_numerical': 0.009993337774816789, 'mean_word_length': 2.708641975308642, 'pattern_counts': {'":': 0, '<': 4, '<?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': '2662330', 'n_tokens_mistral': 475, 'n_tokens_neox': 444, 'n_words': 125}