bench_func returning None for all but the first benchmark
维护者通常 1 天内回复
@amritamishra01 已经在做这个了。
开始于 2025年11月18日。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 38/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- python
- 领域
- performance
调研方向
复现 benchmarks.py 中的示例,然后阅读 pyperf/_runner.py 中的 bench_func,以及 pyperf/_bench.py 和 pyperf/_manager.py 中的基准测试收集路径。确定 manager 进程和 worker 进程之间预期的返回契约,并使行为或文档保持一致,以便将报告的基准测试结果收集到 BenchmarkSuite 中。
由索引模型根据 Issue 内容生成。
描述
I'm trying to write a benchmark suite for several functions and use BenchmarkSuite to write the results to a json file. I have the following code (irrelevant parts removed):
import pyperf
import decimation_accel as dec
import decimation_accel_opt as opt
results_file = 'decimation.json'
runner = pyperf.Runner()
def main() -> None:
small = alloc_args(1024)
small10 = alloc_args(1024, rate=10)
small100 = alloc_args(1024, rate=100)
medium = alloc_args(1024 * 10)
benchmarks: List[pyperf.Benchmark] = []
benchmarks.append(runner.bench_func('dec.decimate_minmax(small) all', dec.minmax, *small))
benchmarks.append(runner.bench_func('opt.decimate_minmax(small) all', opt.minmax, *small))
benchmarks.append(runner.bench_func('dec.decimate_minmax(small10) all', dec.minmax, *small10))
benchmarks.append(runner.bench_func('opt.decimate_minmax(small10) all', opt.minmax, *small10))
benchmarks.append(runner.bench_func('dec.decimate_minmax(small100) all', dec.minmax, *small100))
benchmarks.append(runner.bench_func('opt.decimate_minmax(small100) all', opt.minmax, *small100))
benchmarks.append(runner.bench_func('dec.decimate_minmax(medium) all', dec.minmax, *medium))
benchmarks.append(runner.bench_func('opt.decimate_minmax(medium) all', opt.minmax, *medium))
print(benchmarks)
suite = pyperf.BenchmarkSuite(benchmarks) # filename='decimation.json')
suite.dump(results_file)
if __name__ == "__main__":
main()
However if I run this file, I get the following output:
[<Benchmark 'dec.decimate_minmax(small) all' with 1 runs>, None, None, None, None, None, None, None]
Traceback (most recent call last):
File "benchmarks.py", line 60, in <module>
main()
File "benchmarks.py", line 54, in main
suite = pyperf.BenchmarkSuite(benchmarks) # filename='decimation.json')
File "<REMOVED>/venv-local/lib/python3.8/site-packages/pyperf/_bench.py", line 639, in __init__
self.add_benchmark(benchmark)
File "<REMOVED>/venv-local/lib/python3.8/site-packages/pyperf/_bench.py", line 687, in add_benchmark
name = benchmark.get_name()
AttributeError: 'NoneType' object has no attribute 'get_name'
Traceback (most recent call last):
File "benchmarks.py", line 60, in <module>
main()
File "benchmarks.py", line 39, in main
benchmarks.append(runner.bench_func('dec.decimate_minmax(small) all', dec.minmax, *small))
File "<REMOVED>/venv-local/lib/python3.8/site-packages/pyperf/_runner.py", line 537, in bench_func
result = self._main(task)
File "<REMOVED>/venv-local/lib/python3.8/site-packages/pyperf/_runner.py", line 460, in _main
bench = self._manager()
File "<REMOVED>/venv-local/lib/python3.8/site-packages/pyperf/_runner.py", line 673, in _manager
bench = Manager(self).create_bench()
File "<REMOVED>/venv-local/lib/python3.8/site-packages/pyperf/_manager.py", line 232, in create_bench
worker_bench, run = self.create_worker_bench()
File "<REMOVED>/venv-local/lib/python3.8/site-packages/pyperf/_manager.py", line 131, in create_worker_bench
suite = self.create_suite()
File "<REMOVED>/venv-local/lib/python3.8/site-packages/pyperf/_manager.py", line 121, in create_suite
suite = self.spawn_worker(self.calibrate_loops, 0)
File "<REMOVED>/venv-local/lib/python3.8/site-packages/pyperf/_manager.py", line 107, in spawn_worker
raise RuntimeError("%s failed with exit code %s"
RuntimeError: <REMOVED>/venv-local/bin/python failed with exit code 1
If I don't put the results in the list, then they all appear to run fine, but then I have no way to collect the results.
- 主要语言
- Python
- 星标
- 967
- 派生
- 112
- 平均合并
- 5 天 8 小时
- 30 天内合并 PR
- 9
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
psf/pyperf 的其他 Issue
-
难度 5/5 一周以上 新手友好度 35/100
维护者通常 1 天内回复
-
Improve Type System for `pyperf`可能已有人在做 @DebanKsahu 于 69 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 45/100
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 32/100
维护者通常 1 天内回复
-
Extend hook's teardown metadata with warmup/calibration flags可能已有人在做 @maurycy 于 170 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 48/100
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 20/100
维护者通常 1 天内回复
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 65/100
StevenBlack/hosts#3299 ·
-
`garak --report` overwrites the input report when its name has no ".report"可能已有人在做 @0z5a 今天认领。 未关闭needs-triage
难度 2/5 半天 新手友好度 72/100
维护者通常 2 天内回复
-
plot_graph crashes when a mesh node has no m2m edge可能已有人在做 @tygvi 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
mllam/neural-lam#883 · 1 条评论 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
future-agi/future-agi#4092 · 1 条评论 ·
维护者通常 1 天内回复
-
transcript analytics: a text whose only protected spans the prose pass redacts is withheld whole未关闭
难度 1/5 1 小时以内 新手友好度 82/100
WingedGuardian/GENesis-AGI#4641 ·
维护者通常 1 天内回复