This may sound a bit strange but I was wondering if there is a convenient way or a program that could estimate the number of arithmetic operations (e.g. addition, multiplication etc.) in a code ? I thought about using if statements and counters but the code is a bit big and can be a bit hassle. So I would appreciate if anybody can suggest a more convenient way. Thanks.
Asked
Active
Viewed 852 times
1
-
2[Big-O notation?](http://en.wikipedia.org/wiki/Big_O_notation) – Fredrik Pihl Sep 17 '12 at 11:46
-
you could try to redefine the operations to include the counters. This way you don't have to do it everywhere in the code. – Minion91 Sep 17 '12 at 11:48
-
@Fredrik I don't understand how I can use the big-O notation for this purpose. Do you mind elaborating a bit ? – Cemre Mengü Sep 17 '12 at 11:58
-
1See this [epic answer](http://stackoverflow.com/a/487278/297323). Are you really after the number of arithmetic operation since it can vary with different compilers, optimization settings etc; seems like knowing how a program behaves according to big-o is of more interests... – Fredrik Pihl Sep 17 '12 at 12:02
-
Some profilers might count individual operations, but I doubt that. The problem is that the counting additions and multiplications in a high-level programming language usually makes little sense, except in some highly specialized areas. – Qnan Sep 17 '12 at 15:56
-
It does make sense if you know exactly how many operations are performed, or if you simply assume the absolute minimum number you need. And besides, We are talking matlab here. There is nothing a compiler can do if you use e.g. lots of blas calls. – angainor Sep 17 '12 at 18:38
-
It is worth noting, that many years ago (1980's) either Matlab or Maxsima told you how many operations it performed in a calculation. – John Mar 10 '15 at 16:42