An overlay over a counters file that provides access to the individual counters contained in the file.
| 415 | |
| 416 | |
| 417 | class ChromeCounterCollection(object): |
| 418 | """An overlay over a counters file that provides access to the |
| 419 | individual counters contained in the file.""" |
| 420 | |
| 421 | _HEADER_SIZE = 4 * 4 |
| 422 | _COUNTER_NAME_SIZE = 64 |
| 423 | _THREAD_NAME_SIZE = 32 |
| 424 | |
| 425 | def __init__(self, data): |
| 426 | """Create a new instance. |
| 427 | |
| 428 | Args: |
| 429 | data: the shared data access object |
| 430 | """ |
| 431 | self.data = data |
| 432 | self.max_counters = data.IntAt(8) |
| 433 | self.max_threads = data.IntAt(12) |
| 434 | self.counter_names_offset = \ |
| 435 | self._HEADER_SIZE + self.max_threads * (self._THREAD_NAME_SIZE + 2 * 4) |
| 436 | self.counter_values_offset = \ |
| 437 | self.counter_names_offset + self.max_counters * self._COUNTER_NAME_SIZE |
| 438 | |
| 439 | def CountersInUse(self): |
| 440 | """Return the number of counters in active use.""" |
| 441 | for i in range(self.max_counters): |
| 442 | name_offset = self.counter_names_offset + i * self._COUNTER_NAME_SIZE |
| 443 | if self.data.ByteAt(name_offset) == 0: |
| 444 | return i |
| 445 | return self.max_counters |
| 446 | |
| 447 | def Counter(self, i): |
| 448 | """Return the i'th counter.""" |
| 449 | name_offset = self.counter_names_offset + i * self._COUNTER_NAME_SIZE |
| 450 | value_offset = self.counter_values_offset + i * self.max_threads * 4 |
| 451 | return ChromeCounter(self.data, name_offset, value_offset) |
| 452 | |
| 453 | |
| 454 | def Main(data_file, name_filter): |
no outgoing calls
no test coverage detected
searching dependent graphs…