3 ms·
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
by Waterluvian 3y ago
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.
- c0balt 3y agoYesn'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#instruction-counting https://www.qemu.org/docs/master/devel/replay.html#instructi... more can be found searching the docs.
- choroid 3y agoIai^1 uses CacheGrind^2 to count instructions [1] - https://github.com/bheisler/iai https://github.com/bheisler/iai [2] - https://valgrind.org/docs/manual/cg-manual.html https://valgrind.org/docs/manual/cg-manual.html
- tomsmeding 3y agoOn Intel CPUs yes you can, using perf. See https://www.brendangregg.com/perf.html https://www.brendangregg.com/perf.html ; getting started: perf stat command