<!--
title: explicit performance handling
domain: llm-infra
topic: Performance Optimization
language: Python
source: ggml-org/llama.cpp
updated: 2025-07-07
url: https://awesomereviewers.com/reviewers/llama.cpp-explicit-performance-handling/
-->

When writing performance benchmarking and measurement code, always be explicit about all possible cases and organize related constants clearly. Avoid catch-all else clauses that could mask bugs or unexpected values in performance-critical code paths.

This approach prevents silent failures in benchmark parsing and makes performance code more maintainable by clearly documenting all expected scenarios.

Example of explicit case handling:
```python
# Instead of a catch-all else clause
if unit == "TFLOPS":
    gflops = value * 1000
elif unit == "MFLOPS":
    gflops = value / 1000
elif unit == "GFLOPS":
    gflops = value
else:
    assert False  # Explicit failure for unexpected units
```

Example of organized performance constants:
```python
# Clearly separate constants by benchmark type
LLAMA_BENCH_BOOL_PROPERTIES = ["embeddings", "cpu_strict", "use_mmap", "no_kv_offload", "flash_attn"]
TEST_BACKEND_OPS_BOOL_PROPERTIES = ["supported", "passed"]
```
