@marcel91200 / caddy Mirror · read-only
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 11, 01:00 UTC

master
go 55 lines 2.05 KB
Raw
1 // Copyright 2015 Matthew Holt and The Caddy Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 package caddyhttp
16
17 import (
18 "crypto/tls"
19 "testing"
20 )
21
22 // BenchmarkBuildHTTP3Server_WebTransportOff measures the cost of
23 // constructing the HTTP/3 server for a deployment that does NOT opt in
24 // to WebTransport. This is the primary cost comparison steadytao asked
25 // about: any non-zero delta vs. pre-WebTransport Caddy would need to be
26 // justified, and the implementation is structured so the delta is
27 // exactly the branch check on webTransportEnabled.
28 //
29 // This benchmark does not exercise the per-stream dispatch cost
30 // (which is inside webtransport-go / quic-go and would require a full
31 // QUIC setup to measure in isolation). The meaningful regression guard
32 // is whether buildHTTP3Server with the flag off does the same work
33 // as on pre-PR master.
34 func BenchmarkBuildHTTP3Server_WebTransportOff(b *testing.B) {
35 s := &Server{}
36 tlsCfg := &tls.Config{}
37 b.ResetTimer()
38 for b.Loop() {
39 _ = s.buildHTTP3Server(tlsCfg)
40 }
41 }
42
43 // BenchmarkBuildHTTP3Server_WebTransportOn measures the same
44 // construction with WebTransport enabled. The cost difference vs. the
45 // Off variant is the one-time setup webtransport.ConfigureHTTP3Server
46 // performs (AdditionalSettings, ConnContext, EnableDatagrams, etc.)
47 // plus setting EnableStreamResetPartialDelivery on the QUIC config.
48 func BenchmarkBuildHTTP3Server_WebTransportOn(b *testing.B) {
49 s := &Server{WebTransport: new(WebTransportConfig)}
50 tlsCfg := &tls.Config{}
51 b.ResetTimer()
52 for b.Loop() {
53 _ = s.buildHTTP3Server(tlsCfg)
54 }
55 }