added ability to use unsmoothed raw (for fun)

This commit is contained in:
Miodec 2022-01-18 00:01:36 +01:00
parent c908fcc875
commit 702278a58a
3 changed files with 24 additions and 3 deletions

View file

@ -27,3 +27,4 @@ import * as Account from "./account";
import * as TestStats from "./test-stats";
import * as Replay from "./replay";
import * as TestTimer from "./test-timer";
import * as Result from "./test-timer";

View file

@ -11,10 +11,18 @@ import * as TodayTracker from "./today-tracker";
import * as PbCrown from "./pb-crown";
import * as RateQuotePopup from "./rate-quote-popup";
import * as TestLogic from "./test-logic";
import * as Notifications from "./notifications";
let result;
let maxChartVal;
let useUnsmoothedRaw = false;
export function toggleUnsmoothed() {
useUnsmoothedRaw = !useUnsmoothedRaw;
Notifications.add(useUnsmoothedRaw ? "on" : "off", 1);
}
async function updateGraph() {
ChartController.result.options.annotation.annotations = [];
let labels = [];
@ -33,9 +41,18 @@ async function updateGraph() {
let chartData1 = Config.alwaysShowCPM
? TestStats.wpmHistory.map((a) => a * 5)
: TestStats.wpmHistory;
let chartData2 = Config.alwaysShowCPM
? result.chartData.raw.map((a) => a * 5)
: result.chartData.raw;
let chartData2;
if (useUnsmoothedRaw) {
chartData2 = Config.alwaysShowCPM
? result.chartData.unsmoothedRaw.map((a) => a * 5)
: result.chartData.unsmoothedRaw;
} else {
chartData2 = Config.alwaysShowCPM
? result.chartData.raw.map((a) => a * 5)
: result.chartData.raw;
}
ChartController.result.data.datasets[0].data = chartData1;
ChartController.result.data.datasets[1].data = chartData2;

View file

@ -1480,6 +1480,7 @@ function buildCompletedEvent(difficultyFailed) {
completedEvent.consistency = consistency;
let smoothedraw = Misc.smooth(rawPerSecond, 1);
completedEvent.chartData.raw = smoothedraw;
completedEvent.chartData.unsmoothedRaw = rawPerSecond;
//smoothed consistency
let stddev2 = Misc.stdDev(smoothedraw);
@ -1676,6 +1677,8 @@ export async function finish(difficultyFailed = false) {
dontSave
);
delete completedEvent.chartData.unsmoothedRaw;
if (completedEvent.testDuration > 122) {
completedEvent.chartData = "toolong";
TestStats.setKeypressTimingsTooLong();