1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-09-05 04:42:37 +01:00

WA3 Exsisting Code

This commit is contained in:
Marc Bonnici
2017-02-21 13:37:11 +00:00
parent 067f76adf3
commit 1f1f2b12c6
54 changed files with 9239 additions and 0 deletions

46
wa/utils/counter.py Normal file
View File

@@ -0,0 +1,46 @@
"""
An auto incremeting value (kind of like an AUTO INCREMENT field in SQL).
Optionally, the name of the counter to be used is specified (each counter
increments separately).
Counts start at 1, not 0.
"""
from collections import defaultdict
__all__ = [
'next',
'reset',
'reset_all',
'counter',
]
__counters = defaultdict(int)
def next(name=None):
__counters[name] += 1
value = __counters[name]
return value
def reset_all(value=0):
for k in __counters:
reset(k, value)
def reset(name=None, value=0):
__counters[name] = value
class counter(object):
def __init__(self, name):
self.name = name
def next(self):
return next(self.name)
def reset(self, value=0):
return reset(self.name, value)