fix log limiter, use eng notation
This commit is contained in:
1 parent
4bb3f3424a
commit
de79393dfc
4 files changed
+20
-7
No files matched your search
+15
-3
@@ -57,6 +57,18 @@ def hr_bytes(nbytes):
|
|||||||
multiplier += 1
|
multiplier += 1
|
||||||
return f'{nbytes:.1f}{["", "ki", "Mi", "Gi", "Ti", "Pi"][multiplier]}B'
|
return f'{nbytes:.1f}{["", "ki", "Mi", "Gi", "Ti", "Pi"][multiplier]}B'
|
||||||
|
|
||||||
|
def eng(number):
|
||||||
|
"""Formats a given number using engineering notation."""
|
||||||
|
exponent = 0
|
||||||
|
if abs(number) < 1:
|
||||||
|
while abs(number) >= 1000:
|
||||||
|
number *= 1000
|
||||||
|
exponent -= 3
|
||||||
|
else:
|
||||||
|
while abs(number) >= 1000:
|
||||||
|
number /= 1000
|
||||||
|
exponent += 3
|
||||||
|
return f'{number:.0f}' + (f'e{exponent}' if exponent != 0 else '')
|
||||||
|
|
||||||
def hr_time(seconds):
|
def hr_time(seconds):
|
||||||
"""Formats a given time interval for human readability."""
|
"""Formats a given time interval for human readability."""
|
||||||
@@ -138,10 +150,10 @@ class Log:
|
|||||||
self._limit = limit
|
self._limit = limit
|
||||||
|
|
||||||
def stop_limit(self):
|
def stop_limit(self):
|
||||||
if self.filtered > 0:
|
|
||||||
log.info(f'{self.filtered} more messages (filtered).')
|
|
||||||
self.filtered = 0
|
|
||||||
self._limit = -1
|
self._limit = -1
|
||||||
|
if self.filtered > 0:
|
||||||
|
self.info(f'{self.filtered} more messages (filtered).')
|
||||||
|
self.filtered = 0
|
||||||
|
|
||||||
def __getstate__(self):
|
def __getstate__(self):
|
||||||
return {'elapsed': time.perf_counter() - self.start}
|
return {'elapsed': time.perf_counter() - self.start}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import math
|
|||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
from . import numba, logic, hr_bytes, sim
|
from . import numba, logic, hr_bytes, sim, eng
|
||||||
from .circuit import Circuit
|
from .circuit import Circuit
|
||||||
|
|
||||||
class LogicSim(sim.SimOps):
|
class LogicSim(sim.SimOps):
|
||||||
@@ -44,7 +44,7 @@ class LogicSim(sim.SimOps):
|
|||||||
self.s[:,:,1,:] = 255 # unassigned
|
self.s[:,:,1,:] = 255 # unassigned
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f'{{name: "{self.circuit.name}", sims: {self.sims}, m: {self.m}, c_bytes: {self.c.nbytes}}}'
|
return f'{{name: "{self.circuit.name}", sims: {self.sims}, m: {self.m}, c_bytes: {eng(self.c.nbytes)}}}'
|
||||||
|
|
||||||
def s_to_c(self):
|
def s_to_c(self):
|
||||||
"""Copies the values from ``s[0]`` the inputs of the combinational portion.
|
"""Copies the values from ``s[0]`` the inputs of the combinational portion.
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ class DelayFile:
|
|||||||
|
|
||||||
delays = np.zeros((len(circuit.lines), 2, 2, 3)) # dataset last during construction.
|
delays = np.zeros((len(circuit.lines), 2, 2, 3)) # dataset last during construction.
|
||||||
|
|
||||||
|
with log.limit(50):
|
||||||
for name, iopaths in self.cells.items():
|
for name, iopaths in self.cells.items():
|
||||||
name = name.replace('\\', '')
|
name = name.replace('\\', '')
|
||||||
if cell := circuit.cells.get(name, None):
|
if cell := circuit.cells.get(name, None):
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import math
|
|||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
from . import numba, cuda, sim, cdiv
|
from . import numba, cuda, sim, cdiv, eng
|
||||||
|
|
||||||
|
|
||||||
TMAX = np.float32(2 ** 127)
|
TMAX = np.float32(2 ** 127)
|
||||||
@@ -103,7 +103,7 @@ class WaveSim(sim.SimOps):
|
|||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
dev = 'GPU' if hasattr(self.c, 'copy_to_host') else 'CPU'
|
dev = 'GPU' if hasattr(self.c, 'copy_to_host') else 'CPU'
|
||||||
return f'{{name: "{self.circuit.name}", device: "{dev}", sims: {self.sims}, ops: {len(self.ops)}, ' + \
|
return f'{{name: "{self.circuit.name}", device: "{dev}", sims: {self.sims}, ops: {len(self.ops)}, ' + \
|
||||||
f'levels: {len(self.level_starts)}, nbytes: {self.nbytes}}}'
|
f'levels: {len(self.level_starts)}, nbytes: {eng(self.nbytes)}}}'
|
||||||
|
|
||||||
def s_to_c(self):
|
def s_to_c(self):
|
||||||
"""Transfers values of sequential elements and primary inputs to the combinational portion.
|
"""Transfers values of sequential elements and primary inputs to the combinational portion.
|
||||||
|
|||||||
Reference in new issue
Block a user