<commit_before>var Vec2D = require('../src/Vec2D.js'),
  Suite = require('./Suite');

var VECTOR_COUNT = 100000,
  TEST_PASSES = 5;

console.log('Tests are averaged from %d passes/runs on a set of %d vectors. Please wait...', TEST_PASSES, VECTOR_COUNT);

var av = new Suite(Vec2D.ArrayVector, VECTOR_COUNT, TEST_PASSES).run();
var fv = new Suite(Vec2D.Float32Vector, VECTOR_COUNT, TEST_PASSES).run();
var ov = new Suite(Vec2D.ObjectVector, VECTOR_COUNT, TEST_PASSES).run();

function stats(item) {
  console.log('"%s", %dms', item.name, item.time);
}

console.log('\nFloat32Vector:');
fv.forEach(stats);
global.gc();

setTimeout(function () {
  console.log('\nArrayVector:');
  av.forEach(stats);

  global.gc();

  setTimeout(function () {
    console.log('\nObjectVector:');
    ov.forEach(stats);
  }, 4000);
}, 4000);<commit_msg>Prettify performance/index.js output + add Float64Vector<commit_after>var Vec2D = require('../src/Vec2D.js'),
  Table = require('cli-table'),
  Suite = require('./Suite');

var VECTOR_COUNT = 100000,
  TEST_PASSES = 5;

console.log('Tests are averaged from %d passes/runs on a set of %d vectors. Please wait...', TEST_PASSES, VECTOR_COUNT);

function stats(item) {
  console.log('"%s", %dms', item.name, item.time);
}

function totalTime(items) {
  console.log('%dms', items.reduce(function(sum, item) { return sum + item.time; }, 0));
}

global.gc();
var av = new Suite(Vec2D.ArrayVector, VECTOR_COUNT, TEST_PASSES).run();
console.log('\nArrayVector');
totalTime(av);

global.gc();
var ov = new Suite(Vec2D.ObjectVector, VECTOR_COUNT, TEST_PASSES).run();
console.log('\nObjectVector');
totalTime(ov);

global.gc();
var fv = new Suite(Vec2D.Float32Vector, VECTOR_COUNT, TEST_PASSES).run();
console.log('\nFloat32Vector');
totalTime(fv);

global.gc();
var fv2 = new Suite(Vec2D.Float64Vector, VECTOR_COUNT, TEST_PASSES).run();
console.log('\nFloat64Vector');
totalTime(fv2);

var table = new Table({ head: ['time in ms', 'ArrayVector', 'ObjectVector', 'Float32Vector', 'Float64Vector'] });

for (var i = 0; i < av.length; i++) {
  var row = {};
  row[av[i].name] = [av[i].time, ov[i].time, fv[i].time, fv2[i].time];
  table.push(row);
}

console.log(table.toString());
{'fraction_non_alphanumeric': 0.18772727272727271, 'fraction_numerical': 0.025454545454545455, 'mean_word_length': 5.182584269662922, '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': '5070170', 'n_tokens_mistral': 865, 'n_tokens_neox': 812, 'n_words': 172}