MCPcopy Create free account
hub / github.com/1a1a11a/libCacheSim / _load_size_data

Function _load_size_data

scripts/traceAnalysis/size.py:29–67  ·  view source on GitHub ↗

load size distribution plot data from C++ computation Args: datapath (str): the path of size data file Returns: Tuple[dict, dict]: obj_size_req_cnt, obj_size_obj_cnt

(datapath: str)

Source from the content-addressed store, hash-verified

27
28
29def _load_size_data(datapath: str) -> Tuple[dict, dict]:
30 """load size distribution plot data from C++ computation
31
32 Args:
33 datapath (str): the path of size data file
34
35 Returns:
36 Tuple[dict, dict]: obj_size_req_cnt, obj_size_obj_cnt
37
38 """
39
40 ifile = open(datapath)
41 data_line = ifile.readline()
42 desc_line = ifile.readline()
43 m = re.match(r"# object_size: req_cnt", desc_line)
44 assert (
45 "# object_size: req_cnt" in desc_line or "# object_size: freq" in desc_line
46 ), (
47 "the input file might not be size data file, desc line "
48 + desc_line
49 + " data "
50 + datapath
51 )
52
53 obj_size_req_cnt, obj_size_obj_cnt = {}, {}
54 for line in ifile:
55 if line[0] == "#" and "object_size: obj_cnt" in line:
56 break
57 else:
58 size, count = [int(i) for i in line.split(":")]
59 obj_size_req_cnt[size] = count
60
61 for line in ifile:
62 size, count = [int(i) for i in line.split(":")]
63 obj_size_obj_cnt[size] = count
64
65 ifile.close()
66
67 return obj_size_req_cnt, obj_size_obj_cnt
68
69
70def plot_size_distribution(datapath: str, figname_prefix: str = ""):

Callers 1

plot_size_distributionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected