Imported Upstream version 2.9.0
[debian/cc1111] / support / regression / get_ticks.py
1 import sys, re
2 import string
3
4 """Simple script that scans all of the simulator output text fed in
5 through stdin and summarises the total number of system clock ticks."""
6
7 # Read in everything
8 lines = sys.stdin.readlines()
9
10 # Declare globals
11 bytes = 0
12 ticks = 0
13
14 for line in lines:
15     # 'n words read from ...', where = # bytes in hex file
16     if (re.search(r'words read from', line)):
17         (data, post) = re.split(r'w', line, 1)
18         bytes = string.atoi(data)
19
20     # 'Total time since last reset= 0.102021 sec (i clks)',
21     # where i = # system clock ticks.
22     if (re.search(r'^Total time', line)):
23         (pre, data) = re.split(r'\(', line)
24         (nticks, post) = re.split(r' ', data)
25         ticks = string.atoi(nticks)
26
27 print "\n--- Simulator: %d/%d: %d bytes, %d ticks" % (bytes, ticks, bytes, ticks)