MCPcopy
hub / github.com/elastic/go-elasticsearch / Run

Method Run

_benchmarks/benchmarks/runner/runner.go:168–216  ·  view source on GitHub ↗

Run executes the benchmark runs.

()

Source from the content-addressed store, hash-verified

166
167// Run executes the benchmark runs.
168func (r *Runner) Run() error {
169 if err := validateConfig(r.config); err != nil {
170 return err
171 }
172
173 var errs []error
174
175 r.stats = r.stats[:]
176
177 if r.config.SetupFunc != nil {
178 if _, err := r.config.SetupFunc(0, r.config); err != nil {
179 return err
180 }
181 }
182
183 for n := 1; n <= r.config.NumWarmups; n++ {
184 if _, err := r.config.RunnerFunc(n, r.config); err != nil {
185 errs = append(errs, err)
186 }
187 }
188
189 for n := 1; n <= r.config.NumRepetitions; n++ {
190 stat := Stats{Start: time.Now().UTC()}
191 res, err := r.config.RunnerFunc(n, r.config)
192 if err != nil {
193 errs = append(errs, err)
194 stat.Outcome = "failure"
195 } else {
196 stat.Duration = time.Since(stat.Start)
197 stat.ResponseStatusCode = res.StatusCode
198 if res.IsError() {
199 errs = append(errs, fmt.Errorf("HTTP error: %s", res.String()))
200 stat.Outcome = "failure"
201 } else {
202 stat.Outcome = "success"
203 }
204 r.stats = append(r.stats, stat)
205 }
206 }
207
208 if err := r.SaveStats(); err != nil {
209 return err
210 }
211
212 if len(errs) > 0 {
213 return &Error{err: fmt.Sprintf("encountered %d errors during the run", len(errs)), errs: errs}
214 }
215 return nil
216}
217
218// Stats returns statistics about the run.
219func (r *Runner) Stats() []Stats {

Callers 15

mainFunction · 0.95
TestClientConfigurationFunction · 0.45
TestClientInterfaceFunction · 0.45
TestAddrsToURLsFunction · 0.45
TestCloudIDFunction · 0.45
TestResponseCheckOnlyFunction · 0.45
TestCompatibilityHeaderFunction · 0.45
TestBuildStrippedVersionFunction · 0.45
TestMetaHeaderFunction · 0.45
TestContentTypeOverrideFunction · 0.45
TestInstrumentationFunction · 0.45
TestCloseFunction · 0.45

Calls 4

SaveStatsMethod · 0.95
validateConfigFunction · 0.85
IsErrorMethod · 0.80
StringMethod · 0.45

Tested by 15

TestClientConfigurationFunction · 0.36
TestClientInterfaceFunction · 0.36
TestAddrsToURLsFunction · 0.36
TestCloudIDFunction · 0.36
TestResponseCheckOnlyFunction · 0.36
TestCompatibilityHeaderFunction · 0.36
TestBuildStrippedVersionFunction · 0.36
TestMetaHeaderFunction · 0.36
TestContentTypeOverrideFunction · 0.36
TestInstrumentationFunction · 0.36
TestCloseFunction · 0.36
TestInterceptsFunction · 0.36