<commit_before>#!/usr/bin/env ./node_modules/.bin/babel-node
'use strict';

import Connection from './lib/connection.js';
import ResponseParser from './lib/response_parser.js';
import convertToBuffer from './lib/convert_to_buffer.js';
import StopWatch from './lib/stopwatch.js';

const parser = new ResponseParser();
const conn = new Connection('127.0.0.1', 6379);
const stopwatch = new StopWatch();

const totalRequests = 1000000;

const command = convertToBuffer('PING');

let counter = 0;
const onData = (d) => {
  // console.log(parser.parse(d))
  counter++;
  if (counter == totalRequests) {
    const duration = stopwatch.stop();
    console.log("====== PING_INLINE ======");
    console.log(`  ${totalRequests} requests completed in ${duration} seconds`);    
    console.log("  1 parallel clients");
    console.log("  3 bytes payload");
    console.log("  keep alive: 1");
    console.log("");
    console.log(`${(totalRequests / duration).toFixed(2)} requests per second`);
    
    process.exit();
  }
    
  conn.send(command);
}

conn.receive(onData);

stopwatch.start();
conn.send(command);

//wait for key
process.stdin.on('data', text => {
  var buffer = new Buffer(text, 'utf-8');
  var lastCharacter = buffer[buffer.length - 1];

  // exit on '\n' or '\r'
  if ([10, 13].includes(lastCharacter)) {
    conn.stop();
    process.exit();
  }
});<commit_msg>remove some unneeded code<commit_after>#!/usr/bin/env ./node_modules/.bin/babel-node
'use strict';

import Connection from './lib/connection.js';
import convertToBuffer from './lib/convert_to_buffer.js';
import StopWatch from './lib/stopwatch.js';

const conn = new Connection('127.0.0.1', 6379);
const stopwatch = new StopWatch();

const totalRequests = 1000000;

const command = convertToBuffer('PING');

let counter = 0;
const onData = () => {
  counter++;
  if (counter == totalRequests) {
    const duration = stopwatch.stop();
    console.log('====== PING_INLINE ======');
    console.log(`  ${totalRequests} requests completed in ${duration} seconds`);    
    console.log('  1 parallel clients');
    console.log('  3 bytes payload');
    console.log('  keep alive: 1');
    console.log('');
    console.log(`${(totalRequests / duration).toFixed(2)} requests per second`);
    
    conn.disconnect();
    process.exit();
  }
    
  conn.send(command);
};

conn.receive(onData);

stopwatch.start();
conn.send(command);

//wait for key
process.stdin.on('data', buffer => {
  // exit on '\n' or '\r'
  if ([10, 13].includes(buffer[buffer.length - 1])) {
    conn.disconnect();
    process.exit();
  }
});
{'fraction_non_alphanumeric': 0.18132506780317706, 'fraction_numerical': 0.021309569934134055, 'mean_word_length': 3.7376146788990825, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '2685572', 'n_tokens_mistral': 863, 'n_tokens_neox': 821, 'n_words': 204}