mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-11-18 23:04:30 +08:00
added wpm calculation debug
This commit is contained in:
parent
641dc03f1c
commit
9829665c62
3 changed files with 26 additions and 2 deletions
|
|
@ -58,3 +58,5 @@ extendedGlobal.toggleUnsmoothedRaw = Result.toggleUnsmoothedRaw;
|
|||
extendedGlobal.enableSpacingDebug = TestInput.enableSpacingDebug;
|
||||
|
||||
extendedGlobal.egVideoListener = egVideoListener;
|
||||
|
||||
extendedGlobal.wpmCalculationDebug = TestStats.wpmCalculationDebug;
|
||||
|
|
|
|||
|
|
@ -99,6 +99,12 @@ export function setLastResult(
|
|||
lastResult = result;
|
||||
}
|
||||
|
||||
let wpmCalcDebug = false;
|
||||
export function wpmCalculationDebug(): void {
|
||||
console.log("wpm calculation debug enabled");
|
||||
wpmCalcDebug = true;
|
||||
}
|
||||
|
||||
export function getStats(): DebugStats {
|
||||
const ret: DebugStats = {
|
||||
lastResult,
|
||||
|
|
@ -408,10 +414,16 @@ function countChars(): CharCount {
|
|||
|
||||
export function calculateStats(): Stats {
|
||||
let testSeconds = calculateTestSeconds();
|
||||
// console.log((end2 - start2) / 1000);
|
||||
// console.log(testSeconds);
|
||||
if (wpmCalcDebug) {
|
||||
console.log("date based time", (end2 - start2) / 1000);
|
||||
console.log("performance.now based time", testSeconds);
|
||||
}
|
||||
if (Config.mode != "custom") {
|
||||
testSeconds = Misc.roundTo2(testSeconds);
|
||||
if (wpmCalcDebug) {
|
||||
console.log("mode is not custom - wounding");
|
||||
console.log("new time", testSeconds);
|
||||
}
|
||||
}
|
||||
const chars = countChars();
|
||||
const wpm = Misc.roundTo2(
|
||||
|
|
@ -425,6 +437,15 @@ export function calculateStats(): Stats {
|
|||
(60 / testSeconds)) /
|
||||
5
|
||||
);
|
||||
if (wpmCalcDebug) {
|
||||
console.log("chars", chars);
|
||||
console.log(
|
||||
"wpm",
|
||||
((chars.correctWordChars + chars.correctSpaces) * (60 / testSeconds)) / 5
|
||||
);
|
||||
console.log("wpm rounded to 2", wpm);
|
||||
console.log("wpmraw", wpmraw);
|
||||
}
|
||||
const acc = Misc.roundTo2(calculateAccuracy());
|
||||
return {
|
||||
wpm: isNaN(wpm) ? 0 : wpm,
|
||||
|
|
|
|||
1
frontend/src/ts/types/types.d.ts
vendored
1
frontend/src/ts/types/types.d.ts
vendored
|
|
@ -584,6 +584,7 @@ declare namespace MonkeyTypes {
|
|||
enableSpacingDebug(): void;
|
||||
noGoogleNoMo(): void;
|
||||
egVideoListener(options: Record<string, string>): void;
|
||||
wpmCalculationDebug(): void;
|
||||
}
|
||||
|
||||
interface GithubRelease {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue