Rocky_Mountain_Vending/.pnpm-store/v10/files/c1/86c001dd7a64862013545f51c2b7ea5832e9b3a88df114312120f771866ac430a57c17e839571b6b01de63e29ec75edc946f829dc623359e56fe00de5580ab
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
Next.js website for Rocky Mountain Vending company featuring:
- Product catalog with Stripe integration
- Service areas and parts pages
- Admin dashboard with Clerk authentication
- SEO optimized pages with JSON-LD structured data

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 16:22:15 -07:00

69 lines
No EOL
3.2 KiB
Text

// Copyright 2024 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import * as Core from '../core/core.js';
import * as Graph from '../graph/graph.js';
class Metric {
static getScriptUrls(dependencyGraph, treatNodeAsRenderBlocking) {
const scriptUrls = new Set();
dependencyGraph.traverse(node => {
if (node.type !== Graph.BaseNode.types.NETWORK) {
return;
}
if (node.request.resourceType !== 'Script') {
return;
}
if (treatNodeAsRenderBlocking?.(node)) {
scriptUrls.add(node.request.url);
}
});
return scriptUrls;
}
static get coefficients() {
throw new Core.LanternError('coefficients unimplemented!');
}
/**
* Returns the coefficients, scaled by the throttling settings if needed by the metric.
* Some lantern metrics (speed-index) use components in their estimate that are not
* from the simulator. In this case, we need to adjust the coefficients as the target throttling
* settings change.
*/
static getScaledCoefficients(_rttMs) {
return this.coefficients;
}
static getOptimisticGraph(_dependencyGraph, _processedNavigation) {
throw new Core.LanternError('Optimistic graph unimplemented!');
}
static getPessimisticGraph(_dependencyGraph, _processedNavigation) {
throw new Core.LanternError('Pessmistic graph unimplemented!');
}
static getEstimateFromSimulation(simulationResult, _extras) {
return simulationResult;
}
static compute(data, extras) {
const { simulator, graph, processedNavigation } = data;
const metricName = this.name.replace('Lantern', '');
const optimisticGraph = this.getOptimisticGraph(graph, processedNavigation);
const pessimisticGraph = this.getPessimisticGraph(graph, processedNavigation);
let simulateOptions = { label: `optimistic${metricName}` };
const optimisticSimulation = simulator.simulate(optimisticGraph, simulateOptions);
simulateOptions = { label: `pessimistic${metricName}` };
const pessimisticSimulation = simulator.simulate(pessimisticGraph, simulateOptions);
const optimisticEstimate = this.getEstimateFromSimulation(optimisticSimulation, { ...extras, optimistic: true });
const pessimisticEstimate = this.getEstimateFromSimulation(pessimisticSimulation, { ...extras, optimistic: false });
const coefficients = this.getScaledCoefficients(simulator.rtt);
// Estimates under 1s don't really follow the normal curve fit, minimize the impact of the intercept
const interceptMultiplier = coefficients.intercept > 0 ? Math.min(1, optimisticEstimate.timeInMs / 1000) : 1;
const timing = coefficients.intercept * interceptMultiplier +
coefficients.optimistic * optimisticEstimate.timeInMs + coefficients.pessimistic * pessimisticEstimate.timeInMs;
return {
timing,
optimisticEstimate,
pessimisticEstimate,
optimisticGraph,
pessimisticGraph,
};
}
}
export { Metric };
//# sourceMappingURL=Metric.js.map