本文整理汇总了Python中cache.Cache.print_config方法的典型用法代码示例。如果您正苦于以下问题:Python Cache.print_config方法的具体用法?Python Cache.print_config怎么用?Python Cache.print_config使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cache.Cache
的用法示例。
在下文中一共展示了Cache.print_config方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from cache import Cache [as 别名]
# 或者: from cache.Cache import print_config [as 别名]
def main(argv):
if len(argv) != 1:
print "Usage:"
print "$ python cache-sim.py <trace_file_name>"
sys.exit()
print "Initializing Cache..."
cache_sim = Cache('config')
cache_sim.print_config()
try:
with open(argv[0], "rb") as trace:
print "Processing Instruction Trace..."
i = 0.0
for line in trace:
# Poor man's solution to indicate application is still running
i += 1
if (i % 10**5 == 0):
sys.stdout.write('.')
sys.stdout.flush()
# handle empty lines in the trace file
if line.strip() == '':
continue
words = line.split() # separate words in the line
# if using a different trace format, just change the index and L/S format here
# to match the Load and Store positions and address positions in the trace
# current trace format in use:
# words: 1 48d1e2 -1 5 45 - - L -264 7fffe7ff048 48d1e9 0 CMP LOAD
# index: 0 1 2 3 4 5 6 7 8 9 10 11 12 13
if words[7] == 'L':
inst_node = {'inst' : 'LD', 'addr' : int(words[9], 16)} # address is in hex, read in base 16
cache_sim.run(inst_node)
elif words[7] == 'S':
inst_node = {'inst' : 'ST', 'addr' : int(words[9], 16)} # address is in hex, read in base 16
cache_sim.run(inst_node)
else:
pass
except IOError as error:
print '====== ERROR ====='
print "Error opening file", error.filename
print error.message
sys.exit()
""" Deprecated since high memory usage with large traces (can use with small traces)
print "Loading trace..."
trace_obj = Trace(argv[0])
print "Simulating..."
cache_sim.run(trace_obj.trace)
"""
print "Finished"
cache_sim.print_stats()