KPI dashboards in SCADA systems - Time & Space Complexity
When building KPI dashboards in SCADA systems, it is important to understand how the time to update and display data grows as more data points are added.
We want to know how the system handles larger amounts of data and how that affects performance.
Analyze the time complexity of the following code snippet.
// Fetch and display KPI values
function updateDashboard(kpiList) {
for (let i = 0; i < kpiList.length; i++) {
let kpi = kpiList[i];
let value = fetchKPIValue(kpi.id);
displayValue(kpi.id, value);
}
}
// fetchKPIValue and displayValue are simple functions
This code updates the dashboard by fetching and displaying each KPI value one by one.
Identify the loops, recursion, array traversals that repeat.
- Primary operation: Looping through the list of KPIs to fetch and display each value.
- How many times: Once for each KPI in the list (kpiList.length times).
As the number of KPIs increases, the number of fetch and display operations grows directly with it.
| Input Size (n) | Approx. Operations |
|---|---|
| 10 | 10 fetch and display calls |
| 100 | 100 fetch and display calls |
| 1000 | 1000 fetch and display calls |
Pattern observation: The work grows in a straight line as the number of KPIs increases.
Time Complexity: O(n)
This means the time to update the dashboard grows directly in proportion to the number of KPIs.
[X] Wrong: "Fetching all KPIs at once will take the same time as fetching one KPI."
[OK] Correct: Each KPI requires a separate fetch and display operation, so more KPIs mean more work and more time.
Understanding how dashboard updates scale with data size shows you can think about system performance and user experience, a key skill in real-world DevOps and SCADA work.
"What if we batch fetch all KPI values in one call instead of fetching each separately? How would the time complexity change?"