#coding:utf-8
__author__ = 'zhangxd18'
import sys
import os
import string
if "__main__" == __name__:
if sys.argv < 2:
sys.exit(-1)
map_file = sys.argv[1]
total_size = 0
with open(map_file) as f:
lines = f.readlines()
for i, line in enumerate(lines):
tmp_data = line.split("-", 2)
start_str = tmp_data[0]
end_str = tmp_data[1].split(" ", 2)[0]
start = string.atoi("0x" + start_str, 0)
end = string.atoi("0x" + end_str, 0)
#size = long(start, 0) - long(end, 0)
size = end - start
total_size = total_size + size
print line
print "-------- 0x%x 0x%x, %d Byte, %f KB, %f MB\n\n"%(start, end, size, size/1024.0, size/1024.0/1024.0)
print ("total_size %d Byte, %f KB, %f MB\n\n"%(total_size, total_size/1024.0, total_size/1024.0/1024.0))
网友评论