Did you clear cache before opening an issue?
Is there an existing issue for this?
Does the issue happen when logged in?
Yes
Does the issue happen when logged out?
Yes
Does the issue happen in incognito mode when logged in?
Yes
Does the issue happen in incognito mode when logged out?
Yes
Account name
No response
Account config
No response
Current Behavior
In frontend/src/ts/test/test-stats.ts, the calculateResultStats function currently iterates over the test text twice to calculate characters, once in countChars() and again inside calculateWpmAndRaw(). Both countChars(true) and calculateWpmAndRaw(true, true, testSeconds) are called consecutively, causing redundant loops over the same text data.
Expected Behavior
The character counting should be optimized so the iteration only happens once. The chars object calculated by countChars could be passed to calculateWpmAndRaw so it doesn't have to recalculate it internally.
Steps To Reproduce
- Open the repository locally or on GitHub.
- Navigate to
frontend/src/ts/test/test-stats.ts.
- Go to line 344.
- Notice the existing
//todo: this counts chars twice - once here and once in calculateWpmAndRaw comment.
Environment
- OS: WIndows 11
- Browser: Google Chrome
- Browser Version: 148.0.7778.179 (Official Build) (64-bit)
Anything else?
I would love to be assigned to this issue and submit a PR to fix it!
Did you clear cache before opening an issue?
Is there an existing issue for this?
Does the issue happen when logged in?
Yes
Does the issue happen when logged out?
Yes
Does the issue happen in incognito mode when logged in?
Yes
Does the issue happen in incognito mode when logged out?
Yes
Account name
No response
Account config
No response
Current Behavior
In
frontend/src/ts/test/test-stats.ts, thecalculateResultStatsfunction currently iterates over the test text twice to calculate characters, once incountChars()and again insidecalculateWpmAndRaw(). BothcountChars(true)andcalculateWpmAndRaw(true, true, testSeconds)are called consecutively, causing redundant loops over the same text data.Expected Behavior
The character counting should be optimized so the iteration only happens once. The
charsobject calculated bycountCharscould be passed tocalculateWpmAndRawso it doesn't have to recalculate it internally.Steps To Reproduce
frontend/src/ts/test/test-stats.ts.//todo: this counts chars twice - once here and once in calculateWpmAndRawcomment.Environment
Anything else?
I would love to be assigned to this issue and submit a PR to fix it!