<commit_before>package thx.benchmark.speed;

using thx.core.Arrays;
using thx.core.Iterators;
import thx.core.Timer;

class SpeedTest {
  var cases : Map<ISpeedCase, SpeedResult>;
  var reference : ISpeedCase;
  var index = 0;
  public function new() {
    cases = new Map();
  }

  public function addCase(test : ISpeedCase, isReference = false) {
    if(isReference && null != reference) throw 'reference already set to ${reference.description}';
    cases.set(test, new SpeedResult(index++, test.description, false));
  }

  public function add(description : String, test : Void -> Void, ?isReference = false)
    addAsync(
      description,
      function(repetitions, done) {
        for(i in 0...repetitions)
          test();
        done();
      },
      isReference
    );
<commit_msg>fixed bug where isReference was ignored<commit_after>package thx.benchmark.speed;

using thx.core.Arrays;
using thx.core.Iterators;
import thx.core.Timer;

class SpeedTest {
  var cases : Map<ISpeedCase, SpeedResult>;
  var reference : ISpeedCase;
  var index = 0;
  public function new() {
    cases = new Map();
  }

  public function addCase(test : ISpeedCase, isReference = false) {
    if(isReference && null != reference) throw 'reference already set to ${reference.description}';
    cases.set(test, new SpeedResult(index++, test.description, isReference));
  }

  public function add(description : String, test : Void -> Void, ?isReference = false)
    addAsync(
      description,
      function(repetitions, done) {
        for(i in 0...repetitions)
          test();
        done();
      },
      isReference
    );

{'fraction_non_alphanumeric': 0.11822660098522167, 'fraction_numerical': 0.0024630541871921183, 'mean_word_length': 3.209844559585492, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '232491', 'n_tokens_mistral': 496, 'n_tokens_neox': 489, 'n_words': 135}