Created
March 2, 2023 17:27
-
-
Save mhassanist/e8fd2b07bbdf697d3d31585f112672a1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class OperationCounterNumericProcessor(NumericProcessor): | |
def __init__(self, computations_list): | |
super().__init__(computations_list) | |
self.count_operations = {} | |
def run_one_computation(self, computation): | |
operation = computation["operation"] | |
if operation not in self.count_operations: | |
self.count_operations[operation] = 1 | |
else: | |
self.count_operations[operation] += 1 | |
super().run_one_computation(computation) | |
def show_statistics(self): | |
for key, value in self.count_operations.items(): | |
print(f"operation: {key}, count: {value}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment