MCPcopy Create free account
hub / github.com/dgraph-io/dgraph-benchmarks / Query

Function Query

pbbenchmark/main.go:103–135  ·  view source on GitHub ↗
(entity []string, q1 string, q2 string)

Source from the content-addressed store, hash-verified

101}
102
103func Query(entity []string, q1 string, q2 string) map[int]eRatio {
104 rmap := make(map[int]eRatio)
105
106 conn, err := grpc.Dial(":8081", grpc.WithInsecure())
107 if err != nil {
108 x.Err(glog, err).Fatal("DialTCPConnection")
109 }
110 defer conn.Close()
111 // Client for getting protocol buffer response
112 c := graph.NewDGraphClient(conn)
113
114 // Http client for getting JSON response.
115 hc := &http.Client{Transport: &http.Transport{
116 MaxIdleConnsPerHost: 100,
117 }}
118
119 tInitial := time.Now()
120 counter := 0
121 for time.Now().Sub(tInitial).Seconds() < *numsecs && counter < len(entity) {
122 fmt.Println("counter", counter)
123 d := entity[counter]
124 q := q1 + d + q2
125 ne, r, jl := getRatio(q, hc, c)
126 er := rmap[ne]
127 er.count += 1
128 er.ratio = er.ratio + r
129 er.jsonL = er.jsonL + jl
130 rmap[ne] = er
131 counter++
132 }
133
134 return rmap
135}
136
137func testQuery(entity []string, name string, q1 string, q2 string) {
138 rm := Query(entity, q1, q2)

Callers 1

testQueryFunction · 0.70

Calls 2

getRatioFunction · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected