DEV Community

eth shihao
eth shihao

Posted on

Benchmarking CAM gross-up and controllable caps in integer cents

A tenant with a 10% area share and $5,000 in CAM advances owes $500.00 under a linear cumulative expense cap or $576.25 under a compounded cap. The anchor pool, annual increase, occupancy, and actual expenses stay the same. The cap language moves $76.25 onto the tenant statement.

Normalize the building pool before allocating it

Start with $80,000 of variable controllable common area maintenance (CAM) at 80% occupancy, $20,000 of fixed controllable expense, and $40,000 of fixed uncapped expense. The sample lease grosses variable costs up to a 100% target and applies a $100,000 building-level base-year stop. The controllable cap grows from a separate $100,000 anchor at 5% per year for three years.

Reconciliation step Cumulative Compounded
Variable controllable costs after gross-up $100,000.00 $100,000.00
Controllable pool before cap $120,000.00 $120,000.00
Controllable ceiling $115,000.00 $115,762.50
Recoverable pool with uncapped expenses $155,000.00 $155,762.50
Billable pool after base-year stop $55,000.00 $55,762.50
Tenant charge at 10% $5,500.00 $5,576.25
True-up after advances $500.00 due $576.25 due

The cumulative formula adds three increases of $5,000 to the original anchor. The compounded formula multiplies the anchor by 1.05 three times. Both cap the normalized controllable pool before adding uncapped expenses. If the recoverable pool falls below the stop, the tenant charge floors at zero and posted advances become a credit.

Benchmark the full reconciliation

The fixture checks both caps, the same building at target occupancy, a stop above the expense pool, a one-third tenant share, and a cost beyond JavaScript's safe integer range. It also measures the error from using actual costs as the billable basis on the 80%-occupied building. That shortcut flips a $500.00 receivable into a $1,000.00 credit.

Run the block from the checkout root with Node.js 20 or later. It asserts the expected balances, warms up the calculator, then reports the median of five 60,000-reconciliation runs. Each measured iteration applies the full calculation, including validation. MIT library source

node --input-type=module <<'JS'
import assert from 'node:assert/strict';
import { performance } from 'node:perf_hooks';
import { reconcileCam } from './src/index.js';

const lease = {
  propertyArea: 20_000,
  tenantArea: 2_000,
  fixedControllableCents: 2_000_000,
  variableControllableCents: 8_000_000,
  fixedUncontrollableCents: 4_000_000,
  actualOccupancyBps: 8_000,
  targetOccupancyBps: 10_000,
  cap: {
    mode: 'cumulative', anchorCents: 10_000_000,
    annualIncreaseBps: 500, yearsSinceAnchor: 3,
  },
  baseYearStopCents: 10_000_000,
  advancesCents: 500_000,
};
const cases = [
  [lease, 50_000n],
  [{ ...lease, cap: { ...lease.cap, mode: 'compounded' } }, 57_625n],
  [{ ...lease, actualOccupancyBps: 10_000 }, -100_000n],
  [{ ...lease, baseYearStopCents: 20_000_000 }, -500_000n],
  [{ propertyArea: 3, tenantArea: 1, fixedControllableCents: 25, advancesCents: 3 }, 5n],
  [{
    propertyArea: 2, tenantArea: 1,
    fixedControllableCents: 9_007_199_254_740_993n,
    advancesCents: 4_503_599_627_370_496n,
  }, 1n],
];
for (const [input, expected] of cases) {
  assert.equal(reconcileCam(input).trueUpCents, expected);
}

const rawCostOnly = reconcileCam({ ...lease, targetOccupancyBps: lease.actualOccupancyBps });
const omittedGrossUpError = rawCostOnly.trueUpCents - reconcileCam(lease).trueUpCents;
assert.equal(omittedGrossUpError, -150_000n);
console.log('Signed error from omitting gross-up in cents', String(omittedGrossUpError));

for (let i = 0; i < 3_000; i++) reconcileCam(cases[i % cases.length][0]);
const iterations = 60_000;
const samples = [];
for (let sample = 0; sample < 5; sample++) {
  let checksum = 0n;
  const start = performance.now();
  for (let i = 0; i < iterations; i++) {
    checksum += reconcileCam(cases[i % cases.length][0]).trueUpCents;
  }
  samples.push(performance.now() - start);
  assert.equal(checksum, -4_923_690_000n);
}
samples.sort((a, b) => a - b);
const median = samples[2];
console.log(JSON.stringify({
  node: process.version, platform: process.platform, arch: process.arch,
  iterations, medianMs: Number(median.toFixed(2)),
  statementsPerSecond: Math.round(iterations * 1000 / median),
}));
JS
Enter fullscreen mode Exit fullscreen mode

On arm64 macOS with Node.js 24.14.1, the median for 60,000 reconciliations was 17.81 ms.

Keep the expense classes in the statement

Use integer cents, integer basis points, and the exact area fraction. This implementation rounds each variable gross-up, the cap ceiling, and the final tenant charge to cents, half up. It subtracts posted advances after the tenant charge rounds. Record the rounding policy alongside the lease's occupancy target, controllable categories, cap anchor, and normalized base-year stop so a reviewer can reproduce the true-up.

Switch the demo from cumulative to compounded with the default inputs. The $76.25 difference traces to the controllable ceiling, with the stop and tenant area held constant. Interactive GitHub Pages demo

For statement production and tenant balances, see CAMReconPack and RentLedgerPack.

Top comments (0)