Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to count code execution steps?

Is it prossible to report how many calculations where executed by a section of code?

I know the benchmark gem will report on runtime, but don't believe it'll count the number of calculations done.

Just to be clear, I'm talking about at the processor level.

like image 422
blunders Avatar asked Mar 19 '26 00:03

blunders


1 Answers

About memory usage, if you define the macro CALC_EXACT_MALLOC_SIZE (not sure where, but in ruby.h may work) and recompile Ruby, you will be able to call GC.malloc_allocated_size to know how much memory is allocated by malloc (almost everything), in bytes.

like image 181
Guilherme Bernal Avatar answered Mar 20 '26 13:03

Guilherme Bernal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!