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

Function test_performance_queries

graphlite/tests/dql_tests.rs:508–570  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

506
507#[test]
508fn test_performance_queries() {
509 let fixture = TestFixture::new().expect("Failed to create test fixture");
510 // Setup fresh graph for this test to avoid interference
511 fixture
512 .setup_graph("test_performance_queries")
513 .expect("Failed to setup graph");
514 // Re-insert fraud data since we have a fresh graph
515 fixture
516 .insert_fraud_data()
517 .expect("Failed to insert fraud data");
518
519 // Test query performance on large dataset
520 let start = std::time::Instant::now();
521
522 let result = fixture.assert_query_succeeds(
523 "MATCH (a:Account)-[t:Transaction]->(m:Merchant)
524 RETURN m.category,
525 count(t) as transaction_count,
526 sum(t.amount) as total_amount,
527 avg(t.amount) as avg_amount,
528 min(t.amount) as min_amount,
529 max(t.amount) as max_amount
530 GROUP BY m.category
531 ORDER BY total_amount DESC",
532 );
533
534 let duration = start.elapsed();
535 assert!(
536 duration.as_secs() < 10,
537 "Complex query should complete within 10 seconds"
538 );
539 assert!(!result.rows.is_empty());
540
541 // Test index-friendly queries
542 let start = std::time::Instant::now();
543
544 fixture.assert_query_succeeds(
545 "MATCH (a:Account)
546 WHERE a.id = '4000000001'
547 RETURN a.*",
548 );
549
550 let duration = start.elapsed();
551 assert!(
552 duration.as_millis() < 100,
553 "Index lookup should be very fast"
554 );
555
556 // Test large result set handling
557 let start = std::time::Instant::now();
558
559 let _result = fixture.assert_query_succeeds(
560 "MATCH (a:Account)-[t:Transaction]->(m:Merchant)
561 RETURN a.id, m.name, t.amount, t.timestamp
562 ORDER BY t.amount DESC",
563 );
564
565 let duration = start.elapsed();

Callers

nothing calls this directly

Calls 4

setup_graphMethod · 0.80
insert_fraud_dataMethod · 0.80
elapsedMethod · 0.80
assert_query_succeedsMethod · 0.45

Tested by

no test coverage detected