2 # -*- coding: utf-8 -*-
4 # Copyright (c) 2013-2023. The SimGrid Team.
7 # This program is free software; you can redistribute it and/or modify it
8 # under the terms of the license (GNU LGPL) which comes with this package.
10 # grep -ohrI 'bw=".*"' . | sort | uniq
15 from decimal import Decimal, DecimalException
20 return re.sub(r"(\.\d*?)0*$", r"\1", dec.to_eng_string()).rstrip(".")
23 def convert(xml, formats, attrib):
25 m = re.search(r'%s="(.*?)"' % attrib, xml)
37 tmp = "%s%s" % (to_str(d), f)
40 except DecimalException:
41 print "Error with:", val
43 m = re.search(r'%s="(.*?)"' % attrib, xml)
50 return sorted(((Decimal(i), j) for i, j in ll), key=lambda x: x[0], reverse=True)
53 for root, dirnames, filenames in os.walk(sys.argv[1]):
54 for filename in fnmatch.filter(filenames, '*.xml'):
55 print root, dirnames, filename
56 path = os.path.join(root, filename)
57 xml = open(path).read()
59 power_formats = formats([("1E0", "f"),
67 xml = convert(xml, power_formats, "power")
69 bandwidth_formats = formats([("1E0", "Bps"),
74 xml = convert(xml, bandwidth_formats, "bandwidth")
75 xml = convert(xml, bandwidth_formats, "bw")
76 xml = convert(xml, bandwidth_formats, "bb_bw")
77 xml = convert(xml, bandwidth_formats, "bw_in")
78 xml = convert(xml, bandwidth_formats, "bw_out")
80 time_formats = formats([("1E-12", "ps"),
89 xml = convert(xml, time_formats, "latency")
90 xml = convert(xml, time_formats, "lat")
91 xml = convert(xml, time_formats, "bb_lat")
94 outfile = open(path, "w")