0

I have a data processing algorithm implemented in Python 2.7, and I need to move it on an embedded system (let it be microcontroller or a more advanced board). To choose the hardware I must know how many floating-point operations are performed and how much memory is used in total.

How to determine these efficiently?

trk
  • 342
  • 4
  • 13

1 Answers1

-1

To count the number of operations, you can do something like

class N:

    ops = 0

    def __init__(self, x):
        self.x = x

    def __add__(self, rhs):
        N.ops += 1
        return N(self.x + rhs.x)

result = N(1) + N(2)
assert result.x == 3
assert N.ops == 1

and replace all your floats with N(float)s.

For memory usage see How do I profile memory usage in Python?

C. Yduqoli
  • 1,706
  • 14
  • 18