MCPcopy Create free account
hub / github.com/GraphLite-AI/GraphLite / test_pattern_performance

Function test_pattern_performance

graphlite/tests/pattern_tests.rs:427–485  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

425
426#[test]
427fn test_pattern_performance() {
428 let fixture = TestFixture::with_fraud_data().expect("Failed to create test fixture");
429
430 // Test simple pattern performance
431 let start = std::time::Instant::now();
432
433 fixture.assert_query_succeeds(
434 "MATCH (a:Account)-[t:Transaction]->(m:Merchant)
435 RETURN count(*) as pattern_matches",
436 );
437
438 let simple_duration = start.elapsed();
439 log::debug!("Simple pattern matching took: {:?}", simple_duration);
440
441 // Test complex pattern performance
442 let start = std::time::Instant::now();
443
444 fixture.assert_query_succeeds(
445 "MATCH (a1:Account)-[t1:Transaction]->(m:Merchant)<-[t2:Transaction]-(a2:Account)
446 WHERE a1 <> a2 AND t1.amount > 1000 AND t2.amount > 1000
447 RETURN count(*) as complex_patterns",
448 );
449
450 let complex_duration = start.elapsed();
451 log::debug!("Complex pattern matching took: {:?}", complex_duration);
452
453 // Test variable length pattern performance
454 let start = std::time::Instant::now();
455
456 let result = fixture.query(
457 "MATCH path = (a:Account)-[:Transaction|Purchase]->{1,2}(m:Merchant)
458 WHERE a.balance > 3000
459 RETURN count(path) as var_length_paths",
460 );
461
462 let var_length_duration = start.elapsed();
463 log::debug!(
464 "Variable length pattern matching took: {:?}",
465 var_length_duration
466 );
467
468 // All should complete in reasonable time
469 assert!(
470 simple_duration.as_secs() < 5,
471 "Simple patterns should be fast"
472 );
473 assert!(
474 complex_duration.as_secs() < 15,
475 "Complex patterns should complete reasonably"
476 );
477
478 match result {
479 Ok(_) => assert!(
480 var_length_duration.as_secs() < 30,
481 "Variable length should complete"
482 ),
483 Err(_) => log::debug!("Variable length patterns not supported or too expensive"),
484 }

Callers

nothing calls this directly

Calls 3

elapsedMethod · 0.80
assert_query_succeedsMethod · 0.45
queryMethod · 0.45

Tested by

no test coverage detected