<commit_before>var randomString = require('random-string');
var _ = require('lodash');
var microtime = require("microtime");

var gemfire = require('../..');
var cache = new gemfire.Cache('benchmark/xml/BenchmarkClient.xml');
var region = cache.getRegion("exampleRegion");

region.clear();

console.log("node-gemfire version " + gemfire.version);
console.log("GemFire version " + gemfire.gemfireVersion);

region.put('smoke', { test: 'value' });
if(JSON.stringify(region.get('smoke')) !== JSON.stringify({ test: 'value' })) {
  throw "Smoke test failed.";
}

var keyOptions = {
  length: 8,
  numeric: true,
  letter: true,
  special: false
};

var randomObject = require('../data/randomObject.json');
var gemfireKey = randomString(keyOptions);

var suffix = 0;
function putNObjects(n){
  _.times(n, function(pair) {
    suffix++;
    region.put(gemfireKey + suffix, randomObject);
  });
}

var stringValueOptions = {
  length: 15 * 1024,
  numeric: true,
  letter: true,
  special: true
};

var stringValue = randomString(stringValueOptions);

function putNStrings(n){
  _.times(n, function(pair) {
    suffix++;
    region.put(gemfireKey + suffix, stringValue);
  });
}

function benchmark(numberOfPuts, typeName, callback) {
  var start = microtime.now();

  callback();

  var microseconds = microtime.now() - start;
  var seconds = (microseconds / 1000000);

  var putsPerSecond = Math.round(numberOfPuts / seconds);
  var usecPerPut = Math.round(microseconds / numberOfPuts);

  console.log(
    "(" + typeName + ") " + numberOfPuts + " puts: ", + usecPerPut + " usec/put " + putsPerSecond + " puts/sec"
  );
}

function benchmarkObjects(numberOfPuts){
  benchmark(numberOfPuts, "object", function () {
    putNObjects(numberOfPuts);
  });
}

function benchmarkStrings(numberOfPuts){
  benchmark(numberOfPuts, "string", function () {
    putNStrings(numberOfPuts);
  });
}

_.each([1, 10], function(numberOfPuts){
  benchmarkObjects(numberOfPuts);
});

_.each([100, 1000, 10000], function(numberOfPuts){
  benchmarkStrings(numberOfPuts);
});
<commit_msg>Remove unused code<commit_after>var randomString = require('random-string');
var _ = require('lodash');
var microtime = require("microtime");

var gemfire = require('../..');
var cache = new gemfire.Cache('benchmark/xml/BenchmarkClient.xml');
var region = cache.getRegion("exampleRegion");

region.clear();

console.log("node-gemfire version " + gemfire.version);
console.log("GemFire version " + gemfire.gemfireVersion);

region.put('smoke', { test: 'value' });
if(JSON.stringify(region.get('smoke')) !== JSON.stringify({ test: 'value' })) {
  throw "Smoke test failed.";
}

var keyOptions = {
  length: 8,
  numeric: true,
  letter: true,
  special: false
};

var randomObject = require('../data/randomObject.json');
var gemfireKey = randomString(keyOptions);

var suffix = 0;
function putNObjects(n){
  _.times(n, function() {
    suffix++;
    region.put(gemfireKey + suffix, randomObject);
  });
}

var stringValueOptions = {
  length: 15 * 1024,
  numeric: true,
  letter: true,
  special: true
};

var stringValue = randomString(stringValueOptions);

function putNStrings(n){
  _.times(n, function() {
    suffix++;
    region.put(gemfireKey + suffix, stringValue);
  });
}

function benchmark(numberOfPuts, typeName, callback) {
  var start = microtime.now();

  callback();

  var microseconds = microtime.now() - start;
  var seconds = (microseconds / 1000000);

  var putsPerSecond = Math.round(numberOfPuts / seconds);
  var usecPerPut = Math.round(microseconds / numberOfPuts);

  console.log(
    "(" + typeName + ") " + numberOfPuts + " puts: ", + usecPerPut + " usec/put " + putsPerSecond + " puts/sec"
  );
}

function benchmarkObjects(numberOfPuts){
  benchmark(numberOfPuts, "object", function () {
    putNObjects(numberOfPuts);
  });
}

function benchmarkStrings(numberOfPuts){
  benchmark(numberOfPuts, "string", function () {
    putNStrings(numberOfPuts);
  });
}

_.each([1, 10], function(numberOfPuts){
  benchmarkObjects(numberOfPuts);
});

_.each([100, 1000, 10000], function(numberOfPuts){
  benchmarkStrings(numberOfPuts);
});

{'fraction_non_alphanumeric': 0.1603109059995142, 'fraction_numerical': 0.014573718727228565, 'mean_word_length': 4.743375174337517, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '2615334', 'n_tokens_mistral': 1431, 'n_tokens_neox': 1348, 'n_words': 278}