Coverage for bilby/core/utils/counter.py: 55%
11 statements
« prev ^ index » next coverage.py v7.6.1, created at 2025-05-06 04:57 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2025-05-06 04:57 +0000
1import multiprocessing
4class Counter(object):
5 """
6 General class to count number of times a function is Called, returns total
7 number of function calls
9 Parameters
10 ==========
11 initalval : int, 0
12 number to start counting from
13 """
14 def __init__(self, initval=0):
15 self.val = multiprocessing.RawValue('i', initval)
16 self.lock = multiprocessing.Lock()
18 def increment(self):
19 with self.lock:
20 self.val.value += 1
22 @property
23 def value(self):
24 return self.val.value