Parse benchmark output to extract t/s data (mean±std) Args: output: Benchmark command output output_suffix: Output file suffix Returns: dict: Dictionary with parsed results
(self, output, output_suffix)
| 185 | return None |
| 186 | |
| 187 | def parse_benchmark_output(self, output, output_suffix): |
| 188 | """ |
| 189 | Parse benchmark output to extract t/s data (mean±std) |
| 190 | |
| 191 | Args: |
| 192 | output: Benchmark command output |
| 193 | output_suffix: Output file suffix |
| 194 | |
| 195 | Returns: |
| 196 | dict: Dictionary with parsed results |
| 197 | """ |
| 198 | results = { |
| 199 | 'embedding_type': output_suffix, |
| 200 | 'threads_1': None, |
| 201 | 'threads_2': None, |
| 202 | 'threads_4': None, |
| 203 | 'threads_8': None, |
| 204 | } |
| 205 | |
| 206 | # Parse table data |
| 207 | # Find lines containing pp128 and t/s |
| 208 | lines = output.strip().split('\n') |
| 209 | |
| 210 | for line in lines: |
| 211 | # Skip header and separator lines |
| 212 | if '|' not in line or 'model' in line or '---' in line: |
| 213 | continue |
| 214 | |
| 215 | # Try to extract data |
| 216 | # Format similar to: | bitnet-25 2B I2_S - 2 bpw ternary | 1012.28 MiB | 2.74 B | CPU | 12 | pp128 | 405.73 ± 3.69 | |
| 217 | parts = [p.strip() for p in line.split('|')] |
| 218 | |
| 219 | if len(parts) >= 8 and 'pp128' in parts[6]: |
| 220 | threads_str = parts[5].strip() |
| 221 | throughput_str = parts[7].strip() |
| 222 | |
| 223 | # Extract thread count |
| 224 | try: |
| 225 | threads = int(threads_str) |
| 226 | except: |
| 227 | continue |
| 228 | |
| 229 | # Extract t/s data (format: "405.73 ± 3.69" or "405.73") |
| 230 | # Try to match "mean ± std" format |
| 231 | match_with_std = re.search(r'([\d.]+)\s*±\s*([\d.]+)', throughput_str) |
| 232 | if match_with_std: |
| 233 | mean = float(match_with_std.group(1)) |
| 234 | std = float(match_with_std.group(2)) |
| 235 | throughput = f"{mean:.2f}±{std:.2f}" |
| 236 | else: |
| 237 | # Only mean, no std |
| 238 | match = re.search(r'([\d.]+)', throughput_str) |
| 239 | if match: |
| 240 | throughput = f"{float(match.group(1)):.2f}" |
| 241 | else: |
| 242 | continue |
| 243 | |
| 244 | # Store result based on thread count |