use performance.now() instead of Date
This commit is contained in:
parent
fd6af73f6a
commit
04ba3c131c
5 changed files with 21 additions and 21 deletions
|
|
@ -108,7 +108,7 @@ function Benchmark(bench) {
|
|||
* Main Function. Checks Hollow Knight game completion by analyzing the save file
|
||||
* @param {object} jsonObject Decoded save data in JavaScript Object Notation form (JSON)
|
||||
*/
|
||||
function HKCheckCompletion(jsonObject, benchStart = new Date()) {
|
||||
function HKCheckCompletion(jsonObject, benchStart = performance.now()) {
|
||||
|
||||
// start benchmark
|
||||
// benchHKCCBegin = new Date();
|
||||
|
|
@ -292,7 +292,7 @@ function HKCheckCompletion(jsonObject, benchStart = new Date()) {
|
|||
|
||||
// finish and show benchmark
|
||||
// benchHKCCEnd = new Date();
|
||||
benchmarkTimes.CheckCompletion.timeEnd = new Date();
|
||||
benchmarkTimes.CheckCompletion.timeEnd = performance.now();
|
||||
// console.info("HKCheckCompletion() time (ms) =", benchHKCCEnd - benchHKCCBegin);
|
||||
|
||||
// Benchmark(benchmarkTimes);
|
||||
|
|
@ -1672,7 +1672,7 @@ function CheckHintsTrue(section, dataObject, playerData, worldData) {
|
|||
function HKReadTextArea(textAreaId = "") {
|
||||
|
||||
// start benchmark
|
||||
benchmarkTimes.HKReadTextArea.timeStart = new Date();
|
||||
benchmarkTimes.HKReadTextArea.timeStart = performance.now();
|
||||
|
||||
// starts the main HTML generating function GenerateInnerHTML() and ensures proper checkbox behaviour
|
||||
InitializeHTMLPopulation(HK);
|
||||
|
|
@ -1688,7 +1688,7 @@ function HKReadTextArea(textAreaId = "") {
|
|||
// console.log(jsonObject);
|
||||
|
||||
// end benchmark and show results
|
||||
benchmarkTimes.HKReadTextArea.timeEnd = new Date();
|
||||
benchmarkTimes.HKReadTextArea.timeEnd = performance.now();
|
||||
|
||||
console.info(`HKReadTextArea() time (ms) =`, benchmarkTimes.HKReadTextArea.timeEnd - benchmarkTimes.HKReadTextArea.timeStart);
|
||||
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ function ProcessFileObject() {
|
|||
|
||||
// finish and show benchmark
|
||||
/* benchLSFEnd = new Date(); */
|
||||
benchmarkTimes.LoadSaveFile.timeEnd = new Date();
|
||||
benchmarkTimes.LoadSaveFile.timeEnd = performance.now();
|
||||
/* console.info("LoadSaveFile() time (ms) =", benchLSFEnd - benchLSFBegin); */
|
||||
|
||||
// 4. Analyze the decoded string immediately
|
||||
|
|
@ -114,7 +114,7 @@ function ProcessFileObject() {
|
|||
})();
|
||||
|
||||
// finish total and show benchmark
|
||||
benchmarkTimes.Total.timeEnd = new Date();
|
||||
benchmarkTimes.Total.timeEnd = performance.now();
|
||||
|
||||
Benchmark(benchmarkTimes);
|
||||
/* console.info("Total time (ms) =", benchTotal - benchLSFBegin); */
|
||||
|
|
@ -202,7 +202,7 @@ function AESDecryption(buffer, cipherObject = ECB_STREAM_CIPHER) {
|
|||
|
||||
// Assign actions (functions) to launch when a specific element is used
|
||||
document.getElementById("save-area-file").addEventListener("change", (event) => {
|
||||
LoadSaveFile(event.target, new Date());
|
||||
LoadSaveFile(event.target, performance.now());
|
||||
});
|
||||
document.getElementById("save-area-file").addEventListener("click", (mouseEvent) => {
|
||||
mouseEvent.target.value = "";
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ function CompletionHTML(jsObj, hkGameCompletion) {
|
|||
function GenerateInnerHTML(db) {
|
||||
|
||||
// start benchmarking
|
||||
benchmarkTimes.GenerateInnerHTML.timeStart = new Date();
|
||||
benchmarkTimes.GenerateInnerHTML.timeStart = performance.now();
|
||||
|
||||
let sections = db.sections;
|
||||
|
||||
|
|
@ -497,7 +497,7 @@ function GenerateInnerHTML(db) {
|
|||
document.getElementById("generated").innerHTML = finalHTMLFill;
|
||||
|
||||
// finish benchmarking
|
||||
benchmarkTimes.GenerateInnerHTML.timeEnd = new Date();
|
||||
benchmarkTimes.GenerateInnerHTML.timeEnd = performance.now();
|
||||
}
|
||||
|
||||
function SectionDescription(section) {
|
||||
|
|
@ -1153,7 +1153,7 @@ window.addEventListener('drop', (event) => {
|
|||
const dt = event.dataTransfer;
|
||||
|
||||
/* Launch save file analyzing */
|
||||
LoadSaveFile(dt, new Date());
|
||||
LoadSaveFile(dt, performance.now());
|
||||
|
||||
var label = document.getElementById("save-area-file").nextElementSibling;
|
||||
var labelInitialText = label.innerHTML;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue