(b *testing.B)
| 410 | } |
| 411 | |
| 412 | func BenchmarkGraph_ConcurrentMixedOperations(b *testing.B) { |
| 413 | graph := &testGraph{} |
| 414 | var wg sync.WaitGroup |
| 415 | const numGoroutines = 200 |
| 416 | |
| 417 | b.ResetTimer() |
| 418 | for i := 0; i < b.N; i++ { |
| 419 | // Launch goroutines performing random operations |
| 420 | for j := 0; j < numGoroutines; j++ { |
| 421 | wg.Add(1) |
| 422 | go func(goroutineID int) { |
| 423 | defer wg.Done() |
| 424 | operationCount := 0 |
| 425 | |
| 426 | for operationCount < 50 { |
| 427 | operation := float32(randInt(100)) / 100.0 |
| 428 | |
| 429 | if operation < 0.6 { // 60% reads |
| 430 | // Read operation |
| 431 | testUnit := &testGraphVertex{Name: fmt.Sprintf("bench-read-%d-%d", goroutineID, operationCount)} |
| 432 | forwardEdges := graph.GetForwardAdjacentVertices(testUnit) |
| 433 | reverseEdges := graph.GetReverseAdjacentVertices(testUnit) |
| 434 | |
| 435 | // Just verify no panics (results may be nil for non-existent vertices) |
| 436 | _ = forwardEdges |
| 437 | _ = reverseEdges |
| 438 | } else { // 40% writes |
| 439 | // Write operation |
| 440 | from := &testGraphVertex{Name: fmt.Sprintf("bench-write-%d-%d", goroutineID, operationCount)} |
| 441 | to := &testGraphVertex{Name: fmt.Sprintf("bench-write-target-%d-%d", goroutineID, operationCount)} |
| 442 | graph.AddEdge(from, to, testEdgeCompleted) |
| 443 | } |
| 444 | |
| 445 | operationCount++ |
| 446 | } |
| 447 | }(j) |
| 448 | } |
| 449 | |
| 450 | wg.Wait() |
| 451 | } |
| 452 | } |
nothing calls this directly
no test coverage detected