MCPcopy Create free account
hub / github.com/InfinitiBit/graphbit / run_scenario

Method run_scenario

benchmarks/frameworks/common.py:256–297  ·  view source on GitHub ↗

Run a specific benchmark scenario.

(self, scenario: BenchmarkScenario)

Source from the content-addressed store, hash-verified

254 pass
255
256 async def run_scenario(self, scenario: BenchmarkScenario) -> BenchmarkMetrics:
257 """Run a specific benchmark scenario."""
258 setup_start = time.perf_counter()
259 await self.setup()
260 setup_time = (time.perf_counter() - setup_start) * 1000
261
262 metrics = None
263 try:
264 if scenario == BenchmarkScenario.SIMPLE_TASK:
265 metrics = await self.run_simple_task()
266 elif scenario == BenchmarkScenario.SEQUENTIAL_PIPELINE:
267 metrics = await self.run_sequential_pipeline()
268 elif scenario == BenchmarkScenario.PARALLEL_PIPELINE:
269 metrics = await self.run_parallel_pipeline()
270 elif scenario == BenchmarkScenario.COMPLEX_WORKFLOW:
271 metrics = await self.run_complex_workflow()
272 elif scenario == BenchmarkScenario.MEMORY_INTENSIVE:
273 metrics = await self.run_memory_intensive()
274 elif scenario == BenchmarkScenario.CONCURRENT_TASKS:
275 metrics = await self.run_concurrent_tasks()
276 else:
277 raise ValueError(f"Unknown scenario: {scenario}")
278
279 if metrics is not None:
280 metrics.setup_time_ms = setup_time
281
282 except Exception as e:
283 # Create failure metrics if scenario fails
284 metrics = BenchmarkMetrics()
285 metrics.error_rate = 1.0
286 metrics.setup_time_ms = setup_time
287 # Re-raise the exception so the caller can handle it
288 raise e
289
290 finally:
291 teardown_start = time.perf_counter()
292 await self.teardown()
293 teardown_time = (time.perf_counter() - teardown_start) * 1000
294 if metrics is not None:
295 metrics.teardown_time_ms = teardown_time
296
297 return metrics
298
299
300# Common test scenarios data

Callers 1

Calls 9

setupMethod · 0.95
run_simple_taskMethod · 0.95
run_parallel_pipelineMethod · 0.95
run_complex_workflowMethod · 0.95
run_memory_intensiveMethod · 0.95
run_concurrent_tasksMethod · 0.95
teardownMethod · 0.95
BenchmarkMetricsClass · 0.85

Tested by

no test coverage detected