Convert a fixed usage reading into a saturation percentage and label.

saturation marker A saturation marker compares usage with a limit and keeps the computed percentage scalar.

Saturation Marker Report

used
saturation_marker.js
Replay: real traced execution (multi-file project)
const used = 78;
const limit = 100;
const percent = Math.round((used * 100) / limit);
let saturation = "clear";

if (percent >= 90) {
    saturation = "saturated";
} else if (percent >= 70) {
    saturation = "warm";
}

console.log(`used=${used} percent=${percent} status=${saturation}`);
const used = 45;
const limit = 100;
const percent = Math.round((used * 100) / limit);
let saturation = "clear";

if (percent >= 90) {
    saturation = "saturated";
} else if (percent >= 70) {
    saturation = "warm";
}

console.log(`used=${used} percent=${percent} status=${saturation}`);
const used = 96;
const limit = 100;
const percent = Math.round((used * 100) / limit);
let saturation = "clear";

if (percent >= 90) {
    saturation = "saturated";
} else if (percent >= 70) {
    saturation = "warm";
}

console.log(`used=${used} percent=${percent} status=${saturation}`);
  1. used ← 78, limit ← 100, percent ← 78, saturation ← clear

    1const used→ 78 = 78;  //@used=45, 962const limit→ 100 = 100;3const percent→ 78 = Math.round((used→ 78 * 100) / limit100);4let saturation→ clear = "clear";
  2. if (percent >= 70)

    7    saturation = "saturated";8} else if (percent78 >= 70) {9    saturation = "warm";10}
  3. console.log(`used=${used} percent=${percent} status=${saturation}`);

    9    saturation = "warm";10}1112console.log(`used=${used78} percent=${percent78} status=${saturationwarm}`);
    outputused=78 percent=78 status=warm
  1. used ← 45, limit ← 100, percent ← 45, saturation ← clear

    1const used→ 45 = 45;2const limit→ 100 = 100;3const percent→ 45 = Math.round((used→ 45 * 100) / limit100);4let saturation→ clear = "clear";56if (percent >= 90) {7    saturation = "saturated";8} else if (percent >= 70) {9    saturation = "warm";10}1112console.log(`used=${used45} percent=${percent45} status=${saturationclear}`);
    outputused=45 percent=45 status=clear
  1. used ← 96, limit ← 100, percent ← 96, saturation ← clear

    1const used→ 96 = 96;2const limit→ 100 = 100;3const percent→ 96 = Math.round((used→ 96 * 100) / limit100);4let saturation→ clear = "clear";
  2. if (percent >= 90)

    3const percent = Math.round((used * 100) / limit);4let saturation = "clear";56if (percent96 >= 90) {7    saturation = "saturated";8} else if (percent >= 70) {
  3. console.log(`used=${used} percent=${percent} status=${saturation}`);

    9    saturation = "warm";10}1112console.log(`used=${used96} percent=${percent96} status=${saturationsaturated}`);
    outputused=96 percent=96 status=saturated