@@ -534,3 +534,37 @@ func BuildBasicAuthCredentials(user string, pass string) string {
534
534
s := user + ":" + pass
535
535
return "Basic " + base64 .StdEncoding .EncodeToString ([]byte (s ))
536
536
}
537
+
538
+ func BenchmarkProcessGet (b * testing.B ) {
539
+ s := NewServer ()
540
+ s .SetLogger (log .New (ioutil .Discard , "" , 0 ))
541
+ s .Get ("/echo/(.*)" , func (s string ) string {
542
+ return s
543
+ })
544
+ req := buildTestRequest ("GET" , "/echo/hi" , "" , nil , nil )
545
+ var buf bytes.Buffer
546
+ iob := ioBuffer {input : nil , output : & buf }
547
+ c := scgiConn {wroteHeaders : false , req : req , headers : make (map [string ][]string ), fd : & iob }
548
+ b .ReportAllocs ()
549
+ b .ResetTimer ()
550
+ for i := 0 ; i < b .N ; i ++ {
551
+ s .Process (& c , req )
552
+ }
553
+ }
554
+
555
+ func BenchmarkProcessPost (b * testing.B ) {
556
+ s := NewServer ()
557
+ s .SetLogger (log .New (ioutil .Discard , "" , 0 ))
558
+ s .Post ("/echo/(.*)" , func (s string ) string {
559
+ return s
560
+ })
561
+ req := buildTestRequest ("POST" , "/echo/hi" , "" , nil , nil )
562
+ var buf bytes.Buffer
563
+ iob := ioBuffer {input : nil , output : & buf }
564
+ c := scgiConn {wroteHeaders : false , req : req , headers : make (map [string ][]string ), fd : & iob }
565
+ b .ReportAllocs ()
566
+ b .ResetTimer ()
567
+ for i := 0 ; i < b .N ; i ++ {
568
+ s .Process (& c , req )
569
+ }
570
+ }
0 commit comments