Record optimization results in history.
(
self,
model_name: str,
operation: str,
baseline_time_ms: float,
optimized_time_ms: float,
memory_usage_mb: float,
notes: Optional[str] = None
)
| 232 | conn.commit() |
| 233 | |
| 234 | def record_optimization( |
| 235 | self, |
| 236 | model_name: str, |
| 237 | operation: str, |
| 238 | baseline_time_ms: float, |
| 239 | optimized_time_ms: float, |
| 240 | memory_usage_mb: float, |
| 241 | notes: Optional[str] = None |
| 242 | ): |
| 243 | """Record optimization results in history.""" |
| 244 | speedup = baseline_time_ms / optimized_time_ms if optimized_time_ms > 0 else 0 |
| 245 | |
| 246 | with sqlite3.connect(self.db_path) as conn: |
| 247 | cursor = conn.cursor() |
| 248 | cursor.execute(""" |
| 249 | INSERT INTO optimization_history |
| 250 | (model_name, operation, timestamp, baseline_time_ms, |
| 251 | optimized_time_ms, speedup, memory_usage_mb, notes) |
| 252 | VALUES (?, ?, ?, ?, ?, ?, ?, ?) |
| 253 | """, ( |
| 254 | model_name, |
| 255 | operation, |
| 256 | datetime.now().isoformat(), |
| 257 | baseline_time_ms, |
| 258 | optimized_time_ms, |
| 259 | speedup, |
| 260 | memory_usage_mb, |
| 261 | notes |
| 262 | )) |
| 263 | conn.commit() |
| 264 | |
| 265 | def get_optimization_history( |
| 266 | self, |