benchmark times

This commit is contained in:
ReznoRMichael 2021-07-12 00:45:55 +02:00
commit de18910a2c
4 changed files with 65 additions and 38 deletions

View file

@ -60,20 +60,25 @@ let divEnd = [
let pSpan = "<span class='p-left-small'></span>";
let benchHKCCBegin, benchHKCCEnd;
/* let benchHKCCBegin, benchHKCCEnd; */
let benchmark = {
loadSaveFile: {
let benchmarkTimes = {
LoadSaveFile: {
name: "LoadSaveFile()",
timeStart: 0,
timeEnd: 0
},
checkCompletion: {
CheckCompletion: {
name: "HKCheckCompletion()",
timeStart: 0,
timeEnd: 0
},
total: {
GenerateInnerHTML: {
name: "GenerateInnerHTML()",
timeStart: 0,
timeEnd: 0
},
Total: {
name: "Total",
timeStart: 0,
timeEnd: 0
@ -98,8 +103,8 @@ function Benchmark(bench) {
function HKCheckCompletion(jsonObject) {
// start benchmark
benchHKCCBegin = new Date();
benchmark.checkCompletion.timeStart = new Date();
// benchHKCCBegin = new Date();
benchmarkTimes.CheckCompletion.timeStart = new Date();
let HKPlayerData;
let HKWorldItems;
@ -277,11 +282,11 @@ function HKCheckCompletion(jsonObject) {
/* document.getElementById("save-area").focus({preventScroll: true}); */
// finish and show benchmark
benchHKCCEnd = new Date();
benchmark.checkCompletion.timeEnd = new Date();
console.info("HKCheckCompletion() time (ms) =", benchHKCCEnd - benchHKCCBegin);
// benchHKCCEnd = new Date();
benchmarkTimes.CheckCompletion.timeEnd = new Date();
// console.info("HKCheckCompletion() time (ms) =", benchHKCCEnd - benchHKCCBegin);
Benchmark(benchmark);
// Benchmark(benchmarkTimes);
return true;
}
@ -1739,5 +1744,7 @@ document.getElementById("save-area-read").addEventListener("click", () => {
export {
// to use in LoadSaveFile.js for auto-analyzing file after decoding
HKCheckCompletion
HKCheckCompletion,
benchmarkTimes,
Benchmark
};

View file

@ -10,7 +10,9 @@
const aesjs = require("./aes-js.js");
// For reading the text area after save decoding
import {
HKCheckCompletion
HKCheckCompletion,
benchmarkTimes,
Benchmark
} from "./HKCheckCompletion.js";
const CSHARP_HEADER = [0, 1, 0, 0, 0, 255, 255, 255, 255, 1, 0, 0, 0, 0, 0, 0, 0, 6, 1, 0, 0, 0]; // 22 bytes
@ -23,7 +25,7 @@ const ECB_STREAM_CIPHER = new aesjs.ModeOfOperation.ecb(AES_KEY); // create a ne
// ---------------- Variables ----------------- //
let benchLSFBegin, benchLSFEnd, benchTotal;
/* let benchLSFBegin, benchLSFEnd, benchTotal; */
// ---------------- Functions ----------------- //
@ -41,7 +43,8 @@ function LoadSaveFile(input, time) {
if (inputFileList.length < 1) return false;
// start benchmark
benchLSFBegin = time;
benchmarkTimes.LoadSaveFile.timeStart = time;
benchmarkTimes.Total.timeStart = time;
// Prepares a File object from the first file of the input files for reading as an Array Buffer
let inputFileObject = inputFileList[0];
@ -92,8 +95,9 @@ function ProcessFileObject() {
decodedString = new TextDecoder().decode(inputArrayBuffer);
// finish and show benchmark
benchLSFEnd = new Date();
console.info("LoadSaveFile() time (ms) =", benchLSFEnd - benchLSFBegin);
/* benchLSFEnd = new Date(); */
benchmarkTimes.LoadSaveFile.timeEnd = new Date();
/* console.info("LoadSaveFile() time (ms) =", benchLSFEnd - benchLSFBegin); */
// 4. Analyze the decoded string immediately
try {
@ -110,8 +114,9 @@ function ProcessFileObject() {
})();
// finish total and show benchmark
benchTotal = new Date();
console.info("Total time (ms) =", benchTotal - benchLSFBegin);
benchmarkTimes.Total.timeEnd = new Date();
Benchmark(benchmarkTimes);
/* console.info("Total time (ms) =", benchTotal - benchLSFBegin); */
// alert(`Decoded String: ${decodedString}`);
// alert(`Array Buffer: ${inputArrayBuffer}`);