<commit_before>

var ss = require('..')
  , sock = ss.socket('sub');

sock.connect(3000);

var n = 0;
var ops = 200;
var t = process.hrtime();
var results = [];

sock.on('message', function(msg){
  if (n++ % ops == 0) {
    t = process.hrtime(t);
    var ms = t[1] / 1000 / 1000;
    var persec = (ops * (1000 / ms) | 0);
    results.push(persec);
    process.stdout.write('\r  [' + persec + ' ops/s] [' + n + ']');
    t = process.hrtime();
  }
});

function sum(arr) {
  return arr.reduce(function(sum, n){
    return sum + n;
  });
}

function mean(arr) {
  return sum(arr) / arr.length | 0;
}

function median(arr) {
  arr = arr.sort();
  return arr[arr.length / 2 | 0];
}

process.on('SIGINT', function(){
  console.log('\n');
  console.log('     mean: %d ops/s', mean(results));
  console.log('   median: %d ops/s', median(results));
  console.log();
  process.exit();
});<commit_msg>add total opts and duration in benchmark output<commit_after>

var ss = require('..')
  , sock = ss.socket('sub');

sock.connect(3000);

var n = 0;
var ops = 200;
var t = start = process.hrtime();
var results = [];

console.log();

sock.on('message', function(msg){
  if (n++ % ops == 0) {
    t = process.hrtime(t);
    var ms = t[1] / 1000 / 1000;
    var persec = (ops * (1000 / ms) | 0);
    results.push(persec);
    process.stdout.write('\r  [' + persec + ' ops/s] [' + n + ']');
    t = process.hrtime();
  }
});

function sum(arr) {
  return arr.reduce(function(sum, n){
    return sum + n;
  });
}

function mean(arr) {
  return sum(arr) / arr.length | 0;
}

function median(arr) {
  arr = arr.sort();
  return arr[arr.length / 2 | 0];
}

process.on('SIGINT', function(){
  t = process.hrtime(start);
  console.log('\n');
  console.log('     mean: %d ops/s', mean(results));
  console.log('   median: %d ops/s', median(results));
  console.log('    total: %d ops in %d.%ds', n, t[0], t[1] / 1000 / 1000 | 0);
  console.log();
  process.exit();
});
{'fraction_non_alphanumeric': 0.21634121274409043, 'fraction_numerical': 0.03237410071942446, 'mean_word_length': 2.965376782077393, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5675787', 'n_tokens_mistral': 795, 'n_tokens_neox': 744, 'n_words': 185}