<commit_before>/*
Copyright (C) 2010, <NAME> <<EMAIL>>

See license text in LICENSE file
*/

// Load configuration
var cfg = require("./config").cfg;

// Require modules
var
  assert = require("assert"),
  sys = require("sys"),
  mysql_client = require("../deps/felixge-node-mysql/lib/mysql").Client,
  conn = new mysql_client(),
  rows,
  global_start_time,
  global_total_time;

function selectAsyncBenchmark(callback) {
  var
    start_time,
    total_time;

  start_time = new Date();
  
  conn.query("SELECT * FROM " + cfg.test_table + ";", function (err, results, fields) {
    if (results.length !== cfg.insert_rows_count) {
      sys.puts("\033[31m**** " + cfg.insert_rows_count + " rows inserted" +
               ", but only " + results.length + " rows selected\033[39m");
    }
    assert.deepEqual(results[0], cfg.selected_row_example);
  
    total_time = ((new Date()) - start_time) / 1000;
    sys.puts("**** " + cfg.insert_rows_count + " rows async selected in " + total_time + "s (" + Math.round(cfg.insert_rows_count / total_time) + "/s)");
  
    // Finish benchmark
    global_total_time = ((new Date()) - global_start_time - cfg.delay_before_select) / 1000;
    sys.puts("** Total time is " + global_total_time + "s");
  
    conn.end();
    
    callback.apply()
  });
}

function insertAsyncBenchmark(callback) {
  var
    start_time,
    total_time,<commit_msg>Improve felixge-node-mysql.js<commit_after>/*
Copyright (C) 2010, <NAME> <<EMAIL>>

See license text in LICENSE file
*/

// Load configuration
var cfg = require("./config").cfg;

// Require modules
var
  assert = require("assert"),
  sys = require("sys"),
  mysql_client = require("../deps/felixge-node-mysql/lib/mysql").Client,
  conn = new mysql_client(),
  rows,
  global_start_time,
  global_total_time;

function selectAsyncBenchmark(callback) {
  var
    start_time,
    total_time;

  start_time = new Date();
  
  conn.query("SELECT * FROM " + cfg.test_table + ";", function (err, results, fields) {
    total_time = ((new Date()) - start_time) / 1000;
    sys.puts("**** " + cfg.insert_rows_count + " rows async selected in " + total_time + "s (" + Math.round(cfg.insert_rows_count / total_time) + "/s)");

    // Some tests
    if (results.length !== cfg.insert_rows_count) {
      sys.puts("\033[31m**** " + cfg.insert_rows_count + " rows inserted" +
               ", but only " + results.length + " rows selected\033[39m");
    }
    assert.deepEqual(results[0], cfg.selected_row_example);
  
    // Finish benchmark
    global_total_time = ((new Date()) - global_start_time - cfg.delay_before_select) / 1000;
    sys.puts("** Total time is " + global_total_time + "s");
  
    conn.end();
    
    callback.apply()
  });
}

function insertAsyncBenchmark(callback) {
  var
    start_time,
    total_time,
{'fraction_non_alphanumeric': 0.15667380442541043, 'fraction_numerical': 0.01641684511063526, 'mean_word_length': 3.285932721712538, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '5598409', 'n_tokens_mistral': 978, 'n_tokens_neox': 935, 'n_words': 198}