mirror of
https://github.com/kubernetes-sigs/prometheus-adapter.git
synced 2026-04-07 10:17:51 +00:00
Add vendor folder to git
This commit is contained in:
parent
66cf5eaafb
commit
183585f56f
6916 changed files with 2629581 additions and 1 deletions
51
vendor/github.com/emicklei/go-restful/bench_curly_test.go
generated
vendored
Normal file
51
vendor/github.com/emicklei/go-restful/bench_curly_test.go
generated
vendored
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
package restful
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func setupCurly(container *Container) []string {
|
||||
wsCount := 26
|
||||
rtCount := 26
|
||||
urisCurly := []string{}
|
||||
|
||||
container.Router(CurlyRouter{})
|
||||
for i := 0; i < wsCount; i++ {
|
||||
root := fmt.Sprintf("/%s/{%s}/", string(i+97), string(i+97))
|
||||
ws := new(WebService).Path(root)
|
||||
for j := 0; j < rtCount; j++ {
|
||||
sub := fmt.Sprintf("/%s2/{%s2}", string(j+97), string(j+97))
|
||||
ws.Route(ws.GET(sub).Consumes("application/xml").Produces("application/xml").To(echoCurly))
|
||||
}
|
||||
container.Add(ws)
|
||||
for _, each := range ws.Routes() {
|
||||
urisCurly = append(urisCurly, "http://bench.com"+each.Path)
|
||||
}
|
||||
}
|
||||
return urisCurly
|
||||
}
|
||||
|
||||
func echoCurly(req *Request, resp *Response) {}
|
||||
|
||||
func BenchmarkManyCurly(b *testing.B) {
|
||||
container := NewContainer()
|
||||
urisCurly := setupCurly(container)
|
||||
b.ResetTimer()
|
||||
for t := 0; t < b.N; t++ {
|
||||
for r := 0; r < 1000; r++ {
|
||||
for _, each := range urisCurly {
|
||||
sendNoReturnTo(each, container, t)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func sendNoReturnTo(address string, container *Container, t int) {
|
||||
httpRequest, _ := http.NewRequest("GET", address, nil)
|
||||
httpRequest.Header.Set("Accept", "application/xml")
|
||||
httpWriter := httptest.NewRecorder()
|
||||
container.dispatch(httpWriter, httpRequest)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue