Implement helper class for counting products
To benchmark our algorithms it would be useful to have a class that counts how many times it was multiplied. That way we could make informed choices in implementing optimizations, and even compare our algorithms across versions.
Unknown
class from our test has most of what we need actually. We only need to add a class attribute (those are accessible by all instances of the class) and increment it each time we multiply. Something like this:
class MultiplicationCounter:
multiplications = 0
def __mul__(self, other):
if isinstance(other, type(self):
self.multiplications += 1
...