Skip to content

Commit

Permalink
tools/stats-viewer: Update chromium stats table layout.
Browse files Browse the repository at this point in the history
R=vegorov@chromium.org

Review URL: http://codereview.chromium.org/6992068

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@8064 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
  • Loading branch information
vitalyr@chromium.org committed May 25, 2011
1 parent 5d4a012 commit 5aae8f0
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions tools/stats-viewer.py
Expand Up @@ -104,10 +104,12 @@ def MountSharedData(self):
sys.exit(1) sys.exit(1)
maps_file = open(maps_name, "r") maps_file = open(maps_name, "r")
try: try:
m = re.search(r"/dev/shm/\S*", maps_file.read()) self.data_name = None
if m is not None and os.path.exists(m.group(0)): for m in re.finditer(r"/dev/shm/\S*", maps_file.read()):
self.data_name = m.group(0) if os.path.exists(m.group(0)):
else: self.data_name = m.group(0)
break
if self.data_name is None:
print "Can't find counter file in maps for PID %s." % self.data_name print "Can't find counter file in maps for PID %s." % self.data_name
sys.exit(1) sys.exit(1)
finally: finally:
Expand Down Expand Up @@ -414,7 +416,8 @@ class ChromeCounterCollection(object):
individual counters contained in the file.""" individual counters contained in the file."""


_HEADER_SIZE = 4 * 4 _HEADER_SIZE = 4 * 4
_NAME_SIZE = 32 _COUNTER_NAME_SIZE = 64
_THREAD_NAME_SIZE = 32


def __init__(self, data): def __init__(self, data):
"""Create a new instance. """Create a new instance.
Expand All @@ -426,22 +429,23 @@ def __init__(self, data):
self.max_counters = data.IntAt(8) self.max_counters = data.IntAt(8)
self.max_threads = data.IntAt(12) self.max_threads = data.IntAt(12)
self.counter_names_offset = \ self.counter_names_offset = \
self._HEADER_SIZE + self.max_threads * (self._NAME_SIZE + 2 * 4) self._HEADER_SIZE + self.max_threads * (self._THREAD_NAME_SIZE + 2 * 4)
self.counter_values_offset = \ self.counter_values_offset = \
self.counter_names_offset + self.max_counters * self._NAME_SIZE self.counter_names_offset + self.max_counters * self._COUNTER_NAME_SIZE


def CountersInUse(self): def CountersInUse(self):
"""Return the number of counters in active use.""" """Return the number of counters in active use."""
for i in xrange(self.max_counters): for i in xrange(self.max_counters):
if self.data.ByteAt(self.counter_names_offset + i * self._NAME_SIZE) == 0: name_offset = self.counter_names_offset + i * self._COUNTER_NAME_SIZE
if self.data.ByteAt(name_offset) == 0:
return i return i
return self.max_counters return self.max_counters


def Counter(self, i): def Counter(self, i):
"""Return the i'th counter.""" """Return the i'th counter."""
return ChromeCounter(self.data, name_offset = self.counter_names_offset + i * self._COUNTER_NAME_SIZE
self.counter_names_offset + i * self._NAME_SIZE, value_offset = self.counter_values_offset + i * self.max_threads * 4
self.counter_values_offset + i * self.max_threads * 4) return ChromeCounter(self.data, name_offset, value_offset)




def Main(data_file, name_filter): def Main(data_file, name_filter):
Expand Down

0 comments on commit 5aae8f0

Please sign in to comment.