{"size": 1343, "ext": "js", "max_stars_repo_path": "benchmark.js", "max_stars_repo_name": "MichaelXF/json-parser", "max_stars_repo_stars_event_min_datetime": "2021-11-23T21:18:40.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-23T21:47:02.000Z", "max_issues_repo_path": "benchmark.js", "max_issues_repo_name": "MichaelXF/json-parser", "max_issues_repo_issues_event_min_datetime": "2021-11-24T04:55:23.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-24T20:19:47.000Z", "max_forks_repo_path": "benchmark.js", "max_forks_repo_name": "MichaelXF/json-parser", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 2, "max_issues_count": 7, "max_forks_count": null, "avg_line_length": 17.0, "max_line_length": 67, "alphanum_fraction": 0.5941921072}
// BENCHMARK JSONParse vs JSON.parse method
const JSONParse = require("./src/JSONParse");

function getInputString() {
  return `
{
  "str": "My_String${Math.random()}",
  "ranges": [
    "${Math.random()}",
    "${Math.random()}",
    "${Math.random()}",
    "${Math.random()}",
    "${Math.random()}",
    "${Math.random()}",
    "${Math.random()}"
   ]
}`;
}
var result;

var count = 10000;

/**
 * JSON.parse
 */
var now = Date.now();

for (var i = 0; i < count; i++) {
  result = JSON.parse(getInputString());
}

var end = Date.now();

var ms = end - now;
var avg = ms / count;
var nativeAvg = avg;

console.log(`
  === JSON.parse ===
  TOTAL EXECUTION TIME: ${ms}ms
  AVERAGE ITERATION TIME: ${avg}ms
  ITERATIONS: ${count}
`);

/**
 * JSONParse
 */
now = Date.now();

for (var i = 0; i < count; i++) {
  result = JSONParse(getInputString());
}

end = Date.now();

ms = end - now;
avg = ms / count;

console.log(`
  === JSONParse ===
  TOTAL EXECUTION TIME: ${ms}ms
  AVERAGE ITERATION TIME: ${avg}ms
  ITERATIONS: ${count}
`);

/**
 * Compare results
 */

var times_faster = Math.floor(avg / nativeAvg);
var percent_faster = Math.floor(((avg - nativeAvg) / avg) * 100.0);

console.log(`
  === RESULTS ===
  JSON.parse is ${times_faster}x times faster than JSONParse
  JSON.parse is ${percent_faster}% percent faster than JSONParse

`);
