# fixture 'benchmark' 未找到
可用 fixtures: cache, capfd, ...

- **ID:** `python/pytest-benchmark-not-found`
- **领域:** python
- **类别:** install_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

未安装 pytest-benchmark，因此它提供的 'benchmark' fixture 不可用。常见于将 benchmark 测试复制到未安装开发依赖的仓库。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 7.x | active | — | — |
| 8.x | active | — | — |

## 解决方案

1. **** (97% 成功率)
   ```
   pip install pytest-benchmark

# then
def test_sort(benchmark):
    result = benchmark(sorted, list(range(1000)))
    assert result[0] == 0
   ```
2. **** (90% 成功率)
   ```
   import pytest

pytest.importorskip('pytest_benchmark')

def test_sort(benchmark):
    benchmark(sorted, list(range(1000)))
   ```

## 无效尝试

- **** — Provides no timing, statistics, or comparison; the test gives false confidence. (90% 失败率)
- **** — No integration with pytest reporting, no --benchmark-compare, and noisy CI output. (70% 失败率)
