11cb0ef41Sopenharmony_ci"use strict";
21cb0ef41Sopenharmony_ciexports.__esModule = true;
31cb0ef41Sopenharmony_ci/* eslint-disable @typescript-eslint/no-var-requires */
41cb0ef41Sopenharmony_ci/* eslint-disable no-console */
51cb0ef41Sopenharmony_civar Benchmark = require("benchmark");
61cb0ef41Sopenharmony_civar mod_js_1 = require("./mod.js");
71cb0ef41Sopenharmony_civar fast_levenshtein_1 = require("fast-levenshtein");
81cb0ef41Sopenharmony_civar fs = require("fs");
91cb0ef41Sopenharmony_civar jslevenshtein = require("js-levenshtein");
101cb0ef41Sopenharmony_civar leven = require("leven");
111cb0ef41Sopenharmony_civar levenshteinEditDistance = require("levenshtein-edit-distance");
121cb0ef41Sopenharmony_civar suite = new Benchmark.Suite();
131cb0ef41Sopenharmony_civar randomstring = function (length) {
141cb0ef41Sopenharmony_ci    var result = "";
151cb0ef41Sopenharmony_ci    var characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
161cb0ef41Sopenharmony_ci    var charactersLength = characters.length;
171cb0ef41Sopenharmony_ci    for (var i = 0; i < length; i++) {
181cb0ef41Sopenharmony_ci        result += characters.charAt(Math.floor(Math.random() * charactersLength));
191cb0ef41Sopenharmony_ci    }
201cb0ef41Sopenharmony_ci    return result;
211cb0ef41Sopenharmony_ci};
221cb0ef41Sopenharmony_civar randomstringArr = function (stringSize, arraySize) {
231cb0ef41Sopenharmony_ci    var i = 0;
241cb0ef41Sopenharmony_ci    var arr = [];
251cb0ef41Sopenharmony_ci    for (i = 0; i < arraySize; i++) {
261cb0ef41Sopenharmony_ci        arr.push(randomstring(stringSize));
271cb0ef41Sopenharmony_ci    }
281cb0ef41Sopenharmony_ci    return arr;
291cb0ef41Sopenharmony_ci};
301cb0ef41Sopenharmony_civar arrSize = 1000;
311cb0ef41Sopenharmony_ciif (!fs.existsSync("data.json")) {
321cb0ef41Sopenharmony_ci    var data_1 = [
331cb0ef41Sopenharmony_ci        randomstringArr(4, arrSize),
341cb0ef41Sopenharmony_ci        randomstringArr(8, arrSize),
351cb0ef41Sopenharmony_ci        randomstringArr(16, arrSize),
361cb0ef41Sopenharmony_ci        randomstringArr(32, arrSize),
371cb0ef41Sopenharmony_ci        randomstringArr(64, arrSize),
381cb0ef41Sopenharmony_ci        randomstringArr(128, arrSize),
391cb0ef41Sopenharmony_ci        randomstringArr(256, arrSize),
401cb0ef41Sopenharmony_ci        randomstringArr(512, arrSize),
411cb0ef41Sopenharmony_ci        randomstringArr(1024, arrSize),
421cb0ef41Sopenharmony_ci    ];
431cb0ef41Sopenharmony_ci    fs.writeFileSync("data.json", JSON.stringify(data_1));
441cb0ef41Sopenharmony_ci}
451cb0ef41Sopenharmony_civar data = JSON.parse(fs.readFileSync("data.json", "utf8"));
461cb0ef41Sopenharmony_civar _loop_1 = function (i) {
471cb0ef41Sopenharmony_ci    var datapick = data[i];
481cb0ef41Sopenharmony_ci    if (process.argv[2] !== "no") {
491cb0ef41Sopenharmony_ci        suite
501cb0ef41Sopenharmony_ci            .add("".concat(i, " - js-levenshtein"), function () {
511cb0ef41Sopenharmony_ci            for (var j = 0; j < arrSize - 1; j += 2) {
521cb0ef41Sopenharmony_ci                jslevenshtein(datapick[j], datapick[j + 1]);
531cb0ef41Sopenharmony_ci            }
541cb0ef41Sopenharmony_ci        })
551cb0ef41Sopenharmony_ci            .add("".concat(i, " - leven"), function () {
561cb0ef41Sopenharmony_ci            for (var j = 0; j < arrSize - 1; j += 2) {
571cb0ef41Sopenharmony_ci                leven(datapick[j], datapick[j + 1]);
581cb0ef41Sopenharmony_ci            }
591cb0ef41Sopenharmony_ci        })
601cb0ef41Sopenharmony_ci            .add("".concat(i, " - fast-levenshtein"), function () {
611cb0ef41Sopenharmony_ci            for (var j = 0; j < arrSize - 1; j += 2) {
621cb0ef41Sopenharmony_ci                (0, fast_levenshtein_1.get)(datapick[j], datapick[j + 1]);
631cb0ef41Sopenharmony_ci            }
641cb0ef41Sopenharmony_ci        })
651cb0ef41Sopenharmony_ci            .add("".concat(i, " - levenshtein-edit-distance"), function () {
661cb0ef41Sopenharmony_ci            for (var j = 0; j < arrSize - 1; j += 2) {
671cb0ef41Sopenharmony_ci                levenshteinEditDistance(datapick[j], datapick[j + 1]);
681cb0ef41Sopenharmony_ci            }
691cb0ef41Sopenharmony_ci        });
701cb0ef41Sopenharmony_ci    }
711cb0ef41Sopenharmony_ci    suite.add("".concat(i, " - fastest-levenshtein"), function () {
721cb0ef41Sopenharmony_ci        for (var j = 0; j < arrSize - 1; j += 2) {
731cb0ef41Sopenharmony_ci            (0, mod_js_1.distance)(datapick[j], datapick[j + 1]);
741cb0ef41Sopenharmony_ci        }
751cb0ef41Sopenharmony_ci    });
761cb0ef41Sopenharmony_ci};
771cb0ef41Sopenharmony_ci// BENCHMARKS
781cb0ef41Sopenharmony_cifor (var i = 0; i < 9; i++) {
791cb0ef41Sopenharmony_ci    _loop_1(i);
801cb0ef41Sopenharmony_ci}
811cb0ef41Sopenharmony_civar results = new Map();
821cb0ef41Sopenharmony_cisuite
831cb0ef41Sopenharmony_ci    .on("cycle", function (event) {
841cb0ef41Sopenharmony_ci    console.log(String(event.target));
851cb0ef41Sopenharmony_ci    if (results.has(event.target.name[0])) {
861cb0ef41Sopenharmony_ci        results.get(event.target.name[0]).push(event.target.hz);
871cb0ef41Sopenharmony_ci    }
881cb0ef41Sopenharmony_ci    else {
891cb0ef41Sopenharmony_ci        results.set(event.target.name[0], [event.target.hz]);
901cb0ef41Sopenharmony_ci    }
911cb0ef41Sopenharmony_ci})
921cb0ef41Sopenharmony_ci    .on("complete", function () {
931cb0ef41Sopenharmony_ci    console.log(results);
941cb0ef41Sopenharmony_ci})
951cb0ef41Sopenharmony_ci    // run async
961cb0ef41Sopenharmony_ci    .run({ async: true });
97