struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / get_ticks.py
blobf234e30f7fd130e5551c5a16ffd202715d0e978e
1 import sys, re, io
2 import string
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."""
7 # Read in everything
8 if sys.version_info[0]<3:
9 safe_stdin = sys.stdin
10 else:
11 safe_stdin = io.TextIOWrapper(sys.stdin.buffer, encoding="latin-1")
12 lines = safe_stdin.readlines()
14 # Declare globals
15 bytes = 0
16 ticks = 0
18 for line in lines:
19 # 'n words read from ...', where = # bytes in hex file
20 if (re.search(r'words read from', line)):
21 (data, post) = re.split(r'words', line, 1)
22 data = re.sub(r'[^0-9]',' ',data).strip().split();
23 if len(data)>0:
24 bytes = int(data[-1])
25 else:
26 bytes = 0 # wrong size, but better than blowing up
28 # 'Total time since last reset= 0.102021 sec (i clks)',
29 # where i = # system clock ticks.
30 if (re.search(r'^Total time', line)):
31 (pre, data) = re.split(r'\(', line)
32 (nticks, post) = re.split(r' ', data)
33 ticks = int(nticks)
35 print("\n--- Simulator: %d/%d: %d bytes, %d ticks" % (bytes, ticks, bytes, ticks))