scripts: Added CsvFfrac type
A simple float variant of the CsvFrac type: - frac(1.5,2) => 1/2 (50.0%) - ffrac(1.5,2) => 1.5/2.0 (75.0%) Useful for `make bench-widths` (previously make bench-bus), where we want to find the average buffer utilization: probe readed progged erased b_rbyd+create 1.0/1.0 (100.0%) 13.8/256.0 (5.4%) ∞/4096.0 (∞%) b_rbyd+delete ∞/1.0 (∞%) ∞/256.0 (∞%) ∞/4096.0 (∞%) b_rbyd+fetch 1.0/1.0 (100.0%) ∞/256.0 (∞%) ∞/4096.0 (∞%) b_rbyd+lookup 1.0/1.0 (100.0%) ∞/256.0 (∞%) ∞/4096.0 (∞%) b_rbyd+usage ∞/1.0 (∞%) ∞/256.0 (∞%) ∞/4096.0 (∞%) b_wt_seq+w 1.0/1.0 (100.0%) 31.7/256.0 (12.4%) 4096.0/4096.0 (100.0%) b_wt_random+w 1.0/1.0 (100.0%) 15.3/256.0 (6.0%) 4096.0/4096.0 (100.0%) b_wt_logging+w 1.0/1.0 (100.0%) 15.4/256.0 (6.0%) 4096.0/4096.0 (100.0%) b_wt_many+w 1.0/1.0 (100.0%) 16.1/256.0 (6.3%) 4096.0/4096.0 (100.0%) TOTAL ∞/1.0 (∞%) ∞/256.0 (∞%) ∞/4096.0 (∞%) Now that we have 4 types, the cast matrix gets a bit complicated, but this is side-stepped a bit by a custom __frac__ hook. --- Some other tweaks to csv.py: - Added CsvFold.type to typecheck folds _after_ we know the expr's final type. - Adopted CsvFfrac as an output for most of the math functions/folds - Stopped early termination of typechecking if we change type! This was broken: int(float(1.5) + int(1))
This commit is contained in:
+1
-1
@@ -36,7 +36,7 @@ class CsvInt(co.namedtuple('CsvInt', 'a')):
|
||||
def __new__(cls, a=0):
|
||||
if isinstance(a, CsvInt):
|
||||
return a
|
||||
if isinstance(a, str):
|
||||
elif isinstance(a, str):
|
||||
try:
|
||||
a = int(a, 0)
|
||||
except ValueError:
|
||||
|
||||
Reference in New Issue
Block a user