Replaced 'new Date().getTime()' calls with 'Date.now()' for clarity and performance
This commit is contained in:
parent
9d09146f68
commit
75da5b650c
@ -39,7 +39,7 @@ class Chef {
|
|||||||
*/
|
*/
|
||||||
async bake(input, recipeConfig, options) {
|
async bake(input, recipeConfig, options) {
|
||||||
log.debug("Chef baking");
|
log.debug("Chef baking");
|
||||||
const startTime = new Date().getTime(),
|
const startTime = Date.now(),
|
||||||
recipe = new Recipe(recipeConfig),
|
recipe = new Recipe(recipeConfig),
|
||||||
containsFc = recipe.containsFlowControl(),
|
containsFc = recipe.containsFlowControl(),
|
||||||
notUTF8 = options && "treatAsUtf8" in options && !options.treatAsUtf8;
|
notUTF8 = options && "treatAsUtf8" in options && !options.treatAsUtf8;
|
||||||
@ -84,7 +84,7 @@ class Chef {
|
|||||||
result: await this.dish.get(returnType, notUTF8),
|
result: await this.dish.get(returnType, notUTF8),
|
||||||
type: Dish.enumLookup(this.dish.type),
|
type: Dish.enumLookup(this.dish.type),
|
||||||
progress: progress,
|
progress: progress,
|
||||||
duration: new Date().getTime() - startTime,
|
duration: Date.now() - startTime,
|
||||||
error: error
|
error: error
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -110,7 +110,7 @@ class Chef {
|
|||||||
silentBake(recipeConfig) {
|
silentBake(recipeConfig) {
|
||||||
log.debug("Running silent bake");
|
log.debug("Running silent bake");
|
||||||
|
|
||||||
const startTime = new Date().getTime(),
|
const startTime = Date.now(),
|
||||||
recipe = new Recipe(recipeConfig),
|
recipe = new Recipe(recipeConfig),
|
||||||
dish = new Dish();
|
dish = new Dish();
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ class Chef {
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
// Suppress all errors
|
// Suppress all errors
|
||||||
}
|
}
|
||||||
return new Date().getTime() - startTime;
|
return Date.now() - startTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ class MultipleBombe extends Operation {
|
|||||||
* @param {number} progress - Progress (as a float in the range 0..1)
|
* @param {number} progress - Progress (as a float in the range 0..1)
|
||||||
*/
|
*/
|
||||||
updateStatus(nLoops, nStops, progress, start) {
|
updateStatus(nLoops, nStops, progress, start) {
|
||||||
const elapsed = new Date().getTime() - start;
|
const elapsed = Date.now() - start;
|
||||||
const remaining = (elapsed / progress) * (1 - progress) / 1000;
|
const remaining = (elapsed / progress) * (1 - progress) / 1000;
|
||||||
const hours = Math.floor(remaining / 3600);
|
const hours = Math.floor(remaining / 3600);
|
||||||
const minutes = `0${Math.floor((remaining % 3600) / 60)}`.slice(-2);
|
const minutes = `0${Math.floor((remaining % 3600) / 60)}`.slice(-2);
|
||||||
@ -237,7 +237,7 @@ class MultipleBombe extends Operation {
|
|||||||
const totalRuns = choose(rotors.length, 3) * 6 * fourthRotors.length * reflectors.length;
|
const totalRuns = choose(rotors.length, 3) * 6 * fourthRotors.length * reflectors.length;
|
||||||
let nRuns = 0;
|
let nRuns = 0;
|
||||||
let nStops = 0;
|
let nStops = 0;
|
||||||
const start = new Date().getTime();
|
const start = Date.now();
|
||||||
for (const rotor1 of rotors) {
|
for (const rotor1 of rotors) {
|
||||||
for (const rotor2 of rotors) {
|
for (const rotor2 of rotors) {
|
||||||
if (rotor2 === rotor1) {
|
if (rotor2 === rotor1) {
|
||||||
|
4
src/core/vendor/gost/gostRandom.mjs
vendored
4
src/core/vendor/gost/gostRandom.mjs
vendored
@ -70,7 +70,7 @@ if (typeof document !== 'undefined') {
|
|||||||
try {
|
try {
|
||||||
// Mouse move event to fill random array
|
// Mouse move event to fill random array
|
||||||
document.addEventListener('mousemove', function (e) {
|
document.addEventListener('mousemove', function (e) {
|
||||||
randomRing.set((new Date().getTime() & 255) ^
|
randomRing.set((Date.now() & 255) ^
|
||||||
((e.clientX || e.pageX) & 255) ^
|
((e.clientX || e.pageX) & 255) ^
|
||||||
((e.clientY || e.pageY) & 255));
|
((e.clientY || e.pageY) & 255));
|
||||||
}, false);
|
}, false);
|
||||||
@ -80,7 +80,7 @@ if (typeof document !== 'undefined') {
|
|||||||
try {
|
try {
|
||||||
// Keypress event to fill random array
|
// Keypress event to fill random array
|
||||||
document.addEventListener('keydown', function (e) {
|
document.addEventListener('keydown', function (e) {
|
||||||
randomRing.set((new Date().getTime() & 255) ^
|
randomRing.set((Date.now() & 255) ^
|
||||||
(e.keyCode & 255));
|
(e.keyCode & 255));
|
||||||
}, false);
|
}, false);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -37,7 +37,7 @@ class WindowWaiter {
|
|||||||
* focus is returned.
|
* focus is returned.
|
||||||
*/
|
*/
|
||||||
windowBlur() {
|
windowBlur() {
|
||||||
this.windowBlurTime = new Date().getTime();
|
this.windowBlurTime = Date.now();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ class WindowWaiter {
|
|||||||
* a long time and the browser has swapped out all its memory.
|
* a long time and the browser has swapped out all its memory.
|
||||||
*/
|
*/
|
||||||
windowFocus() {
|
windowFocus() {
|
||||||
const unfocusedTime = new Date().getTime() - this.windowBlurTime;
|
const unfocusedTime = Date.now() - this.windowBlurTime;
|
||||||
if (unfocusedTime > 60000) {
|
if (unfocusedTime > 60000) {
|
||||||
this.app.silentBake();
|
this.app.silentBake();
|
||||||
}
|
}
|
||||||
|
@ -375,7 +375,7 @@ class WorkerWaiter {
|
|||||||
*/
|
*/
|
||||||
bakingComplete() {
|
bakingComplete() {
|
||||||
this.setBakingStatus(false);
|
this.setBakingStatus(false);
|
||||||
let duration = new Date().getTime() - this.bakeStartTime;
|
let duration = Date.now() - this.bakeStartTime;
|
||||||
duration = duration.toLocaleString() + "ms";
|
duration = duration.toLocaleString() + "ms";
|
||||||
const progress = this.getBakeProgress();
|
const progress = this.getBakeProgress();
|
||||||
|
|
||||||
@ -489,7 +489,7 @@ class WorkerWaiter {
|
|||||||
bake(recipeConfig, options, progress, step) {
|
bake(recipeConfig, options, progress, step) {
|
||||||
this.setBakingStatus(true);
|
this.setBakingStatus(true);
|
||||||
this.manager.recipe.updateBreakpointIndicator(false);
|
this.manager.recipe.updateBreakpointIndicator(false);
|
||||||
this.bakeStartTime = new Date().getTime();
|
this.bakeStartTime = Date.now();
|
||||||
this.bakeId++;
|
this.bakeId++;
|
||||||
this.recipeConfig = recipeConfig;
|
this.recipeConfig = recipeConfig;
|
||||||
this.options = options;
|
this.options = options;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user