3

I'm looking for a programmatic way of counting the number of floating point operations (flops) in call to a function, in JAVA.

There are several closely related questions, asking about what floating points are, and how to do big-O computational complexity analysis, for example here, here and here. But note that in my application I don't want a big-O number, I want to know for a particular run of a function (i.e. a particular input data size) how many flops did it take.

The two closest solutions I can find are (1) suggestions to use a run-time profiler to count the number of flops, but this does not suit my needs as I need to use the result later in the program and (2) a library of computation functions which can be called to increment a counter, and a closely related suggestion here.

These last two suggestions would meet my needs but involve a lot of manual modifications to the code I need to count. An alternative would be to just use CPU run-time which would be very quick and easy, but also quite rough.

Is anyone aware of a programmatic way of counting the flops executed by a section of code?

Community
  • 1
  • 1
kabdulla
  • 5,199
  • 3
  • 17
  • 30

0 Answers0