openai_gateway_passthrough_image_intent_benchmark_test.go 821 B

123456789101112131415161718192021222324252627
  1. package service
  2. import "testing"
  3. var passthroughImageIntentBenchmarkSink bool
  4. func BenchmarkOpenAIPassthroughImageIntentReuse_LargeBody(b *testing.B) {
  5. body := buildLargeOpenAIResponsesImageToolBody(32 << 20)
  6. b.Run("Once", func(b *testing.B) {
  7. b.SetBytes(int64(len(body)))
  8. b.ReportAllocs()
  9. for i := 0; i < b.N; i++ {
  10. passthroughImageIntentBenchmarkSink = IsImageGenerationIntent(openAIResponsesEndpoint, "gpt-5.4", body)
  11. }
  12. })
  13. b.Run("Twice", func(b *testing.B) {
  14. b.SetBytes(int64(len(body)))
  15. b.ReportAllocs()
  16. for i := 0; i < b.N; i++ {
  17. permissionIntent := IsImageGenerationIntent(openAIResponsesEndpoint, "gpt-5.4", body)
  18. billingIntent := IsImageGenerationIntent(openAIResponsesEndpoint, "gpt-5.4", body)
  19. passthroughImageIntentBenchmarkSink = permissionIntent && billingIntent
  20. }
  21. })
  22. }