Capacity reports are easier to read when raw demand is paired with remaining reserve and a stable/watch/tight label. The selector changes only the demand value.

Program

Play the program to choose demand and inspect the reserve label.

demand
capacity_reserve_reliability_report.dart
Replay: real traced execution (multi-file project)
String capacityLabel(int reserve) {
  if (reserve >= 20) {
    return 'stable';
  }
  if (reserve >= 10) {
    return 'watch';
  }
  return 'tight';
}

void main() {
  var demand = 72;
  var capacity = 100;
  var reserve = capacity - demand;
  var status = capacityLabel(reserve);
  var line = 'demand=$demand reserve=$reserve status=$status';
  print(line);
}
String capacityLabel(int reserve) {
  if (reserve >= 20) {
    return 'stable';
  }
  if (reserve >= 10) {
    return 'watch';
  }
  return 'tight';
}

void main() {
  var demand = 88;
  var capacity = 100;
  var reserve = capacity - demand;
  var status = capacityLabel(reserve);
  var line = 'demand=$demand reserve=$reserve status=$status';
  print(line);
}
String capacityLabel(int reserve) {
  if (reserve >= 20) {
    return 'stable';
  }
  if (reserve >= 10) {
    return 'watch';
  }
  return 'tight';
}

void main() {
  var demand = 95;
  var capacity = 100;
  var reserve = capacity - demand;
  var status = capacityLabel(reserve);
  var line = 'demand=$demand reserve=$reserve status=$status';
  print(line);
}
  1. demand ← 72

    11void main() {12  var demand = 72;13  var capacity = 100;
    values this step72demand
  2. capacity ← 100

    12var demand = 72;13var capacity = 100;14var reserve = capacity - demand;
    values this step100capacity
  3. reserve ← 28

    13var capacity = 100;14var reserve = capacity - demand;15var status = capacityLabel(reserve);
    values this step28reserve100capacity72demand
  4. call ← capacityLabel(28)

    14var reserve = capacity - demand;15var status = capacityLabel(reserve);16var line = 'demand=$demand reserve=$reserve status=$status';
    values this stepcapacityLabel(28)call28reserve
  5. condition ← true

    1String capacityLabel(int reserve) {2  if (reserve >= 20) {3    return 'stable';
    values this steptruecondition28reserve
  6. return ← stable

    2if (reserve >= 20) {3  return 'stable';4}
    values this stepstablereturn
  7. status ← stable

    14var reserve = capacity - demand;15var status = capacityLabel(reserve);16var line = 'demand=$demand reserve=$reserve status=$status';
    values this stepstablestatus
  8. line ← demand=72 reserve=28 status=stable

    15var status = capacityLabel(reserve);16var line = 'demand=$demand reserve=$reserve status=$status';17print(line);
    values this stepdemand=72 reserve=28 status=stableline72demand28reservestablestatus
  9. print(line);

    16  var line = 'demand=$demand reserve=$reserve status=$status';17  print(line);18}
    outputdemand=72 reserve=28 status=stable
    values this stepdemand=72 reserve=28 status=stableline
  1. demand ← 88

    11void main() {12  var demand = 88;13  var capacity = 100;
    values this step88demand
  2. capacity ← 100

    12var demand = 88;13var capacity = 100;14var reserve = capacity - demand;
    values this step100capacity
  3. reserve ← 12

    13var capacity = 100;14var reserve = capacity - demand;15var status = capacityLabel(reserve);
    values this step12reserve100capacity88demand
  4. call ← capacityLabel(12)

    14var reserve = capacity - demand;15var status = capacityLabel(reserve);16var line = 'demand=$demand reserve=$reserve status=$status';
    values this stepcapacityLabel(12)call12reserve
  5. condition ← false

    1String capacityLabel(int reserve) {2  if (reserve >= 20) {3    return 'stable';
    values this stepfalsecondition12reserve
  6. condition ← true

    4}5if (reserve >= 10) {6  return 'watch';
    values this steptruecondition12reserve
  7. return ← watch

    5if (reserve >= 10) {6  return 'watch';7}
    values this stepwatchreturn
  8. status ← watch

    14var reserve = capacity - demand;15var status = capacityLabel(reserve);16var line = 'demand=$demand reserve=$reserve status=$status';
    values this stepwatchstatus
  9. line ← demand=88 reserve=12 status=watch

    15var status = capacityLabel(reserve);16var line = 'demand=$demand reserve=$reserve status=$status';17print(line);
    values this stepdemand=88 reserve=12 status=watchline88demand12reservewatchstatus
  10. print(line);

    16  var line = 'demand=$demand reserve=$reserve status=$status';17  print(line);18}
    outputdemand=88 reserve=12 status=watch
    values this stepdemand=88 reserve=12 status=watchline
  1. demand ← 95

    11void main() {12  var demand = 95;13  var capacity = 100;
    values this step95demand
  2. capacity ← 100

    12var demand = 95;13var capacity = 100;14var reserve = capacity - demand;
    values this step100capacity
  3. reserve ← 5

    13var capacity = 100;14var reserve = capacity - demand;15var status = capacityLabel(reserve);
    values this step5reserve100capacity95demand
  4. call ← capacityLabel(5)

    14var reserve = capacity - demand;15var status = capacityLabel(reserve);16var line = 'demand=$demand reserve=$reserve status=$status';
    values this stepcapacityLabel(5)call5reserve
  5. condition ← false

    1String capacityLabel(int reserve) {2  if (reserve >= 20) {3    return 'stable';
    values this stepfalsecondition5reserve
  6. condition ← false

    4}5if (reserve >= 10) {6  return 'watch';
    values this stepfalsecondition5reserve
  7. return ← tight

    7  }8  return 'tight';9}
    values this steptightreturn
  8. status ← tight

    14var reserve = capacity - demand;15var status = capacityLabel(reserve);16var line = 'demand=$demand reserve=$reserve status=$status';
    values this steptightstatus
  9. line ← demand=95 reserve=5 status=tight

    15var status = capacityLabel(reserve);16var line = 'demand=$demand reserve=$reserve status=$status';17print(line);
    values this stepdemand=95 reserve=5 status=tightline95demand5reservetightstatus
  10. print(line);

    16  var line = 'demand=$demand reserve=$reserve status=$status';17  print(line);18}
    outputdemand=95 reserve=5 status=tight
    values this stepdemand=95 reserve=5 status=tightline
reserve `capacity - demand` turns the raw request level into remaining headroom.
threshold labels `capacityLabel` maps reserve into `stable`, `watch`, or `tight`.
report row The output keeps demand, reserve, and status in one row.