Hacker News new | past | comments | ask | show | jobs | submit login

I’ve wondered about something like that. Is it possible to get the number of cpu operations some test takes? I get with modern CPUs it won’t be as exact as when I was counting 8080 operations, but it would surely tell you something.

Or at higher level abstractions, things like how many Python byte codes.




Yesn't, you can by, e.g., using qemu[0]. This however has the obvious downside of not accounting for pipelining and cache as well as the subset of instructions encoded in microcode vs. hardware. All of those are very important but CPU (microarchitecture, cache) specific.

[0]: For example: https://www.qemu.org/docs/master/devel/replay.html#instructi... more can be found searching the docs.


Iai^1 uses CacheGrind^2 to count instructions

[1] - https://github.com/bheisler/iai [2] - https://valgrind.org/docs/manual/cg-manual.html


On Intel CPUs yes you can, using perf. See https://www.brendangregg.com/perf.html ; getting started: perf stat command




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: