Every schedulability test, from the Liu and Layland bound to response-time analysis, rests on one number per task: its worst-case execution time (WCET). If that number is too low, every guarantee built on it is void. If it is far too high, you buy faster hardware than you need or reject designs that would have worked. Obtaining WCET values that are both safe and tight is one of the hardest problems in real-time engineering, and it has become harder as processors added caches, deep pipelines and multiple cores.
This article surveys the four main families of WCET analysis (static, measurement-based, hybrid and probabilistic), explains how each works, where it fits and where it breaks, and closes with practical guidance for choosing a method. For the scheduling side of the story, see our response-time analysis worked example, which consumes the WCET values discussed here.
Key takeaways
- The WCET is the longest execution time of a piece of code on a given platform over all inputs and initial hardware states; analyses produce an upper bound that should be safe (never below the true WCET) and tight (not much above it).
- Static analysis combines flow analysis, microarchitectural modeling via abstract interpretation and path analysis (typically IPET with integer linear programming) to compute a provable bound without running the code.
- Measurement-based analysis observes execution on real hardware; it is accessible and realistic but cannot prove that the worst case was exercised.
- Hybrid methods measure small program segments and combine them using the program structure; probabilistic methods such as MBPTA estimate a WCET with a stated exceedance probability.
- Multicore interference is now the dominant challenge, and certification guidance in avionics explicitly addresses it.
What WCET is and why it is hard to find
For a task running alone on a given processor, every execution takes some time between the best-case execution time (BCET) and the WCET. Variation comes from three sources:
- Software paths: branches, loops with data-dependent iteration counts, and calls to different functions depending on inputs.
- Input data: the same path can take different times, for example with variable-latency division or floating-point operations.
- Hardware state: the contents of caches, branch predictors, pipelines, TLBs and DRAM row buffers at the start of execution and as it proceeds.
The exact WCET is generally uncomputable because it would require exploring every input combined with every hardware state. Analysis methods therefore produce an estimate or bound. The quality of a bound has two dimensions: safety (it is never exceeded) and tightness (the overestimation is small). Any method trades these against cost and applicability.
Timing anomalies
Intuition suggests that a cache miss can only make execution slower. On complex processors that is not always true. Lundqvist and Stenström (1999) described timing anomalies, where a locally faster event (a cache hit instead of a miss) leads to a globally longer execution, for example by changing the order in which instructions are dispatched to functional units. Anomalies mean an analysis cannot simply assume the “locally worst” outcome at each step; it must consider several possibilities, which raises analysis cost and favors simpler, more predictable hardware for critical systems.
Static WCET analysis
Static analysis computes a bound from the executable binary and a model of the processor, without running the code. It is the approach most associated with provable guarantees and is the reference in the survey by Wilhelm et al. (2008). It proceeds in three stages.
1. Flow analysis
The analyzer reconstructs the control-flow graph from the binary and determines facts about feasible paths: loop bounds, recursion depths and infeasible paths (combinations of branches that cannot occur together). Value analysis derives many loop bounds automatically; others must be supplied as annotations by the developer. Missing or wrong annotations are the most common source of both failed and unsafe analyses.
2. Microarchitectural analysis
Next, the analyzer determines safe execution-time bounds for each basic block, accounting for the processor state. The dominant technique is abstract interpretation, which computes over-approximations of all possible hardware states at each program point. For caches, Ferdinand and Wilhelm’s classic analyses classify each memory access:
- Must analysis finds accesses guaranteed to hit (always-hit).
- May analysis finds accesses guaranteed to miss (always-miss).
- Persistence analysis finds blocks that, once loaded, are never evicted within a scope, so they miss at most once (first-miss).
Pipeline analysis then simulates abstract pipeline states for each block. Cache replacement policy matters greatly: LRU is well understood and analyzable, whereas pseudo-random or some pseudo-LRU policies yield far less precise results.
3. Path analysis with IPET
Finally, the block bounds are combined into a program bound. The standard technique is the Implicit Path Enumeration Technique (IPET) of Li and Malik (1995). Rather than enumerating paths, IPET assigns each basic block an execution count variable x and maximizes total time subject to linear flow constraints, solved as an integer linear program (ILP).
Consider a function with an entry block B1 (5 cycles), a loop header B2 (2 cycles), a loop body containing an if-then-else with branches B3 (10 cycles) and B4 (4 cycles), and an exit block B5 (3 cycles). The loop body runs at most 10 times.
maximize 5·x1 + 2·x2 + 10·x3 + 4·x4 + 3·x5
subject to x1 = 1 (function entered once)
x2 = x1 + x3 + x4 (header: entry edge + back edges)
x3 + x4 ≤ 10 · x1 (loop bound annotation)
x5 = x1 (function exits once)
all x ≥ 0, integer
| Scenario | x1 | x2 | x3 (then) | x4 (else) | x5 | WCET bound (cycles) |
|---|---|---|---|---|---|---|
| Loop bound only | 1 | 11 | 10 | 0 | 1 | 5 + 22 + 100 + 0 + 3 = 130 |
| Plus infeasible-path fact x3 ≤ 3 | 1 | 11 | 3 | 7 | 1 | 5 + 22 + 30 + 28 + 3 = 88 |
The second row shows the value of flow facts: if the developer knows the expensive branch can be taken at most three times (for example, because it handles a rare error condition with a retry limit), adding that constraint tightens the bound by about a third. In real analyses, block costs differ between the first and later iterations because of cache effects, which IPET handles by splitting blocks into contexts.
Strengths and limits of static analysis: it yields a bound that is safe relative to the hardware model, covers all inputs, and needs no test harness. Its weaknesses are the need for an accurate, validated processor model (often unavailable for modern high-performance cores), potential pessimism, and effort for annotations.
Measurement-based timing analysis
Measurement-based analysis runs the code on the target hardware, records execution times and takes the maximum observed value, the high-water mark. Timing is captured with cycle counters, GPIO toggling with an oscilloscope or logic analyzer, software instrumentation, or non-intrusive hardware trace interfaces.
Its appeal is obvious: it measures the real system, including effects no model captures, and it fits existing test infrastructure. Its fundamental weakness is equally clear: you only observe what you exercise. There is no guarantee that tests triggered the worst-case path combined with the worst-case cache and pipeline state. Practitioners compensate with:
- Safety margins, often a fixed percentage added to the high-water mark; the size is a matter of engineering judgment rather than proof.
- Structural coverage targets so that all paths and branches are exercised at least once.
- Stress scenarios: cache flushing before execution, worst-case data patterns, and on multicore platforms, concurrent stressor tasks.
For soft and firm real-time systems, and as supporting evidence for hard ones, measurement-based analysis is indispensable. On its own it is rarely accepted as the sole argument for the highest integrity levels.
Hybrid methods
Hybrid analysis combines the realism of measurement with the coverage of static path analysis. The code is divided into segments, often basic blocks or the code between instrumentation points. Execution times of each segment are measured on the real target during testing, and the measured segment maxima are then combined using a structural model of the program (a syntax tree or an IPET formulation) with loop bounds taken from analysis or observation.
The result can exceed any single end-to-end measurement, because it assumes the worst observed segment times can coincide along the longest feasible path. That makes hybrid estimates more robust than raw high-water marks, without requiring a full processor model. This line of work grew from research at the University of York in the early 2000s (for example, Bernat, Colin and Petters, 2002) and was commercialized by Rapita Systems, which was also one of the FRESCOR project partners.
Hybrid methods still depend on test quality: a segment never executed in its worst hardware context will have an optimistic measured time. Good practice requires coverage evidence at segment level and careful treatment of context-dependent effects such as caches.
Probabilistic timing analysis
Probabilistic methods replace the single WCET value with a probabilistic WCET (pWCET) distribution: a curve giving, for each execution time, the probability that one run exceeds it. A system designer then picks a value whose exceedance probability is acceptably low compared to other failure rates, such as 10⁻⁹ per run.
The best-known measurement variant is Measurement-Based Probabilistic Timing Analysis (MBPTA), introduced by Cucu-Grosjean et al. (2012) and associated with the European PROARTIS project. MBPTA fits Extreme Value Theory distributions to the tail of observed execution times. EVT is valid only if observations meet statistical conditions, such as being independent and identically distributed or satisfying weaker stationarity criteria. To meet them, the approach was paired with time-randomized hardware, for example caches with random placement and replacement, so that execution times behave like random variables rather than depending deterministically on memory layout.
Static probabilistic analysis (SPTA) applies similar ideas analytically. Probabilistic methods remain an active research area. Their main debates concern the representativeness of measurements, the validity of EVT assumptions on conventional deterministic hardware, and how certification authorities should treat probabilistic arguments.
Comparing the methods
| Method | Basis | Safety argument | Typical tightness | Main requirements | Best suited for |
|---|---|---|---|---|---|
| Static | Binary plus hardware model | Strong, relative to model correctness | Good on simple cores; pessimistic on complex ones | Validated processor model, annotations | Highest-integrity code on analyzable processors |
| Measurement-based | End-to-end observations | Weak; depends on test coverage and margins | Optimistic risk unless margins are added | Target hardware, test harness | Soft and firm tasks, early estimates, validation |
| Hybrid | Segment measurements plus structure | Moderate; depends on segment coverage | Usually tighter than static, safer than raw measurement | Instrumentation or trace, coverage data | Complex processors where models are unavailable |
| Probabilistic (MBPTA) | Statistics of observations (EVT) | Probabilistic, with stated exceedance level | Can be tight at chosen probability | Statistical validity, often randomized hardware | Research, systems with explicit probabilistic safety budgets |
The multicore problem
On a multicore processor, a task’s execution time depends on what runs on the other cores. Shared last-level caches, interconnects and memory controllers create interference that can multiply execution times in pathological cases. Single-core WCET methods do not account for it.
Avionics certification guidance addresses this directly: the Certification Authorities Software Team position paper CAST-32A and its successor material, EASA AMC 20-193 and the corresponding FAA advisory circular, require applicants to identify interference channels and show that their effects are bounded. Common strategies include:
- Partitioning shared resources: cache coloring or way-locking, memory bank partitioning.
- Regulating access: memory bandwidth budgets enforced per core, time-division arbitration.
- Measuring interference with dedicated stressors that saturate each shared resource while the task under analysis runs.
- Interference-aware analysis that adds bounded delay terms to single-core WCETs.
These questions connect closely with multicore real-time scheduling and with mixed-criticality systems, which use different WCET estimates at different assurance levels.
Choosing a method in practice
Write analyzable code. Whatever method you use, timing analysis is far easier when loops have static bounds, recursion and dynamic allocation are avoided in time-critical paths, function pointers have known target sets, and hardware features such as caches are configured deterministically.
A sensible workflow for a hard real-time project looks like this:
- Early estimates from measurement on prototypes to size the processor and budget utilization.
- Select the evidence level each function needs based on its criticality and the applicable standard, such as DO-178C in avionics or ISO 26262 in automotive.
- Apply static or hybrid analysis to critical functions, using measurement to cross-check results: a static bound below an observed time indicates a modeling error.
- Feed WCETs into schedulability analysis with overheads, as in RM or EDF tests, and protect less certain tasks with budget enforcement, as in contract-based scheduling.
- Re-analyze on every change to code, compiler options or hardware configuration.
Terms such as BCET, pWCET and IPET are defined in our glossary. For applied help, our WCET and timing analysis service combines measurement and structural analysis for your target, and The Embedded Timing Field Guide collects checklists for instrumenting and measuring embedded code. To see how WCET budgets drive the design of a demanding control system, read timing in UAV flight control.
Frequently asked questions
What is the difference between WCET and worst-case response time?
WCET is the execution time of a task running alone without interruption. Worst-case response time adds interference from higher-priority tasks, blocking and jitter, and is computed by schedulability analysis using WCET as input.
Can I just add 20% to the longest measured time?
That is common practice for non-critical software, but the margin has no formal justification: the true worst case could exceed it if tests never triggered the worst path or hardware state. For safety-critical functions, back measurements with structural or static analysis.
Does static WCET analysis work on any processor?
Only on processors for which an accurate timing model exists. Simple microcontrollers and some cores designed for predictability are well supported; complex out-of-order cores with undocumented features are difficult or impossible to model precisely.
What exceedance probability is used for a pWCET?
It depends on the system’s safety targets. Research papers often illustrate values on the order of 10⁻⁹ to 10⁻¹⁵ per run, chosen to be negligible relative to other failure rates; the appropriate value must be justified for each application.
How do compilers affect WCET?
Significantly. Optimization levels, inlining and code layout change both execution paths and cache behavior. Because analysis works on the final binary, any change in compiler version or flags requires re-analysis.
References and further reading
- Wilhelm, R. et al. (2008). “The Worst-Case Execution-Time Problem: Overview of Methods and Survey of Tools.” ACM Transactions on Embedded Computing Systems, 7(3).
- Li, Y.-T. S. and Malik, S. (1995). “Performance Analysis of Embedded Software Using Implicit Path Enumeration.” Proceedings of the ACM/IEEE Design Automation Conference.
- Ferdinand, C. and Wilhelm, R. (1999). “Efficient and Precise Cache Behavior Prediction for Real-Time Systems.” Real-Time Systems, 17(2–3).
- Lundqvist, T. and Stenström, P. (1999). “Timing Anomalies in Dynamically Scheduled Microprocessors.” Proceedings of the IEEE Real-Time Systems Symposium.
- Bernat, G., Colin, A. and Petters, S. M. (2002). “WCET Analysis of Probabilistic Hard Real-Time Systems.” Proceedings of the IEEE Real-Time Systems Symposium.
- Cucu-Grosjean, L. et al. (2012). “Measurement-Based Probabilistic Timing Analysis for Multi-path Programs.” Proceedings of the Euromicro Conference on Real-Time Systems (ECRTS).
- Worst-case execution time — Wikipedia
- Abstract interpretation — Wikipedia
- Extreme value theory — Wikipedia