<commit_before>var Experiment = require('../experiment.js');

// TODO: generalize to run over a range of input sizes

Experiment.run(
  Experiment.seq(

    // this actually isn't a good way to pick sorting networks for N > 3, since
    // optimal networks usually include duplicate comparisons, and ordering is
    // _crucial_ to even validity of the search; this is only here as an
    // expedient for demo
    Experiment.permute('network'),

    Experiment.permute('input'),

    Experiment.stabalize('runtime'),

    Experiment.counted('rel'),
    Experiment.counted('swap'),

    Experiment.compute(function valid(output, rel) {
      for (var i=0, n=output.length-1; i<n; i++)
        if (! rel(output[i], output[i+1]))
          return false;
      return true;
    }),

    Experiment.copy('input', 'output'),
    Experiment.timed(
      Experiment.under(function(spec, emit) {
        var A       = spec.output;
        var network = spec.network;
        for (var i=0, n=network.length; i<n; i++) {
          var j = network[i][0];
          var k = network[i][1];
          if (spec.rel(A[k], A[j]))
            spec.swap(A, j, k);
        }
        emit(spec);
      })
    )

  ),

  {
    input: [0, 1, 2],
    network: [[0, 1], [1, 2], [0, 2]],
    rel: function(a, b) {return a<b;},
    swap: function(A, i, j) {
      var tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    }
  },

  Experiment.emitSepRecords(process.stdout)
);
<commit_msg>Note derp<commit_after>var Experiment = require('../experiment.js');

// TODO: generalize to run over a range of input sizes

Experiment.run(
  Experiment.seq(

    // this actually isn't a good way to pick sorting networks for N > 3, since
    // optimal networks usually include duplicate comparisons, and ordering is
    // _crucial_ to even validity of the search; this is only here as an
    // expedient for demo
    Experiment.permute('network'),

    Experiment.permute('input'),

    Experiment.stabalize('runtime'),

    Experiment.counted('rel'),
    Experiment.counted('swap'),

    Experiment.compute(function valid(output, rel) {
      // FIXME: this inflates the rels count by N
      for (var i=0, n=output.length-1; i<n; i++)
        if (! rel(output[i], output[i+1]))
          return false;
      return true;
    }),

    Experiment.copy('input', 'output'),
    Experiment.timed(
      Experiment.under(function(spec, emit) {
        var A       = spec.output;
        var network = spec.network;
        for (var i=0, n=network.length; i<n; i++) {
          var j = network[i][0];
          var k = network[i][1];
          if (spec.rel(A[k], A[j]))
            spec.swap(A, j, k);
        }
        emit(spec);
      })
    )

  ),

  {
    input: [0, 1, 2],
    network: [[0, 1], [1, 2], [0, 2]],
    rel: function(a, b) {return a<b;},
    swap: function(A, i, j) {
      var tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    }
  },

  Experiment.emitSepRecords(process.stdout)
);

{'fraction_non_alphanumeric': 0.1553234501347709, 'fraction_numerical': 0.01078167115902965, 'mean_word_length': 2.3025583982202447, 'pattern_counts': {'":': 0, '<': 9, '<?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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '941766', 'n_tokens_mistral': 1027, 'n_tokens_neox': 981, 'n_words': 275}