github.com/macb/etcd@v0.3.1-0.20140227003422-a60481c6b1a0/tests/functional/etcd_direct_call.go (about)

     1  package test
     2  
     3  import (
     4  	"net/http"
     5  	"os"
     6  	"testing"
     7  	"time"
     8  )
     9  
    10  func BenchmarkEtcdDirectCall(b *testing.B) {
    11  	templateBenchmarkEtcdDirectCall(b, false)
    12  }
    13  
    14  func BenchmarkEtcdDirectCallTls(b *testing.B) {
    15  	templateBenchmarkEtcdDirectCall(b, true)
    16  }
    17  
    18  func templateBenchmarkEtcdDirectCall(b *testing.B, tls bool) {
    19  	procAttr := new(os.ProcAttr)
    20  	procAttr.Files = []*os.File{nil, os.Stdout, os.Stderr}
    21  
    22  	clusterSize := 3
    23  	_, etcds, _ := CreateCluster(clusterSize, procAttr, tls)
    24  
    25  	defer DestroyCluster(etcds)
    26  
    27  	time.Sleep(time.Second)
    28  
    29  	b.ResetTimer()
    30  	for i := 0; i < b.N; i++ {
    31  		resp, _ := http.Get("http://127.0.0.1:4001/test/speed")
    32  		resp.Body.Close()
    33  	}
    34  }