const API_EXPECTED_TIME = 1000; const SOME_OTHER_EXPECTED_TIME = 2000; function init() { let t0 = performance.now(); fetch(`${VERY_SERIOUS_API_URL}`).then(response => { const apiRoundtrip = performance.now() - t0; setPerformanceScalar(apiRoundtrip, API_EXPECTED_TIME); // Do stuff }); } function setPerformanceScalar(observed, expected) { const performanceScalar = observed / expected; // ... // tuck this away in app state, local storage, a global variable, etc } function getPerformanceScalar() { // retreive your saved performance data return performanceScalar; } //...