#!/usr/bin/env python3 import sys import re # Regex to capture the last floating-point number before "tokens per second" pattern = re.compile(r'([\d.]+)\s+tokens per second') values = [] for line in sys.stdin: match = pattern.search(line) if match: values.append(float(match.group(1))) if not values: print("Average tokens per second: 0.00") else: num = len(values) avg = sum(values) / num print(f"Average tokens per second: {avg:.2f} out of {num} samples")