diff --git a/src/average-intensity.ts b/src/averageIntensity.ts similarity index 100% rename from src/average-intensity.ts rename to src/averageIntensity.ts diff --git a/src/index.ts b/src/index.ts index f22c92d..e5b7442 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,10 +1,11 @@ import * as fs from "fs"; -import { averageIntensity } from "./average-intensity"; -import { normalizedIntensity } from "./normalized-intensity"; +import { averageIntensity } from "./averageIntensity"; +import { normalizedIntensity } from "./normalizedIntensity"; import { parse } from "./parser"; import { tokenize } from "./tokenizer"; import { totalDuration } from "./totalDuration"; import { tss } from "./tss"; +import { tss2 } from "./tss2"; const filename = process.argv[2]; @@ -33,3 +34,10 @@ console.log( normalizedIntensity(workout.intervals) * 100 ).toFixed()}%` ); + +console.log( + `TSS: ${tss2( + totalDuration(workout.intervals), + normalizedIntensity(workout.intervals) + )}` +); diff --git a/src/normalized-intensity.ts b/src/normalizedIntensity.ts similarity index 100% rename from src/normalized-intensity.ts rename to src/normalizedIntensity.ts diff --git a/src/tss2.ts b/src/tss2.ts new file mode 100644 index 0000000..efddc76 --- /dev/null +++ b/src/tss2.ts @@ -0,0 +1,16 @@ +// Training Stress Score formula from Training and Racing with a Power Meter: +// +// TSS = (s * W * IF) / (FTP * 3600) * 100 +// +// s - duration in seconds +// W - power in watts +// IF - intensity factor (power / FTP) +// +// Derive a formula without power values, using intensities alone: +// +// TSS = (s * (FTP * IF) * IF) / (FTP * 3600) * 100 +// TSS = (s * IF * IF) / 3600 * 100 + +export const tss2 = (duration: number, intensity: number): number => { + return ((duration * intensity * intensity) / 3600) * 100; +};