mirror of
https://github.com/gravitational/teleport.git
synced 2026-09-24 16:17:11 +08:00
* benchmark package
* use default config if path is not specified
* progressiveBench as a config method
* implement a main.go approach to run progressive tests
* make teleport client, run specified benchmark
* function and method descriptions
* make teleport client
* testing
* change interface method signatures
* dry up bench.go code, move producer goroutines to own function
* output formatting
* remove yaml
* fix linter errors
* remove print
* PR suggested changes, moved export latency profile functionality to the benchmark package
* PR fixes
* method description
* update testing
* linter
* docs and example
* PR suggestion changes
* fix coord omission bug
* remove benchmark struct
* remove threads, using open system
* recover in run
* close channel, check if open with each execution
* update testing, pr suggestions
* add more instructions to readme
* update example.go
* pass back context
* use SyncBuffer
* export response and service histograms
* update readme, exporting profiles section
* return from execute()
* export singular latency profile
* export response profile
* Revert "export response profile"
This reverts commit 5a21cb034c.
* export response profile
* update branch
* format example.go
* remove threads
* update example.go
* update branch
* goimports
* add signal handler & update docs
* PR suggestions
* exit out of interactive session
* revert execute
* PR suggestion
* run commmand on non-interactive instead of nil
71 lines
1.9 KiB
Go
71 lines
1.9 KiB
Go
/*
|
|
Copyright 2020 Gravitational, Inc.
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
package benchmark
|
|
|
|
import (
|
|
"errors"
|
|
"time"
|
|
)
|
|
|
|
// Linear generator
|
|
type Linear struct {
|
|
// LowerBound is the lower end of rps to execute
|
|
LowerBound int
|
|
// UpperBound is the upper end of rps to execute
|
|
UpperBound int
|
|
// Step is the amount of rps to increment by
|
|
Step int
|
|
// MinimumMeasurements is the minimum measurement a benchmark should execute
|
|
MinimumMeasurements int
|
|
// MinimumWindow is the minimum duration to run benchmark for
|
|
MinimumWindow time.Duration
|
|
currentRPS int
|
|
config *Config
|
|
}
|
|
|
|
// GetBenchmark returns the benchmark config for the current generation.
|
|
func (lg *Linear) GetBenchmark() *Config {
|
|
cnf := &Config{
|
|
MinimumWindow: lg.MinimumWindow,
|
|
MinimumMeasurements: lg.MinimumMeasurements,
|
|
Rate: lg.currentRPS,
|
|
Command: lg.config.Command,
|
|
}
|
|
|
|
if lg.currentRPS < lg.LowerBound {
|
|
lg.currentRPS = lg.LowerBound
|
|
cnf.Rate = lg.currentRPS
|
|
return cnf
|
|
}
|
|
|
|
lg.currentRPS += lg.Step
|
|
cnf.Rate = lg.currentRPS
|
|
if lg.currentRPS > lg.UpperBound {
|
|
return nil
|
|
}
|
|
return cnf
|
|
}
|
|
|
|
func validateConfig(lg *Linear) error {
|
|
if lg.MinimumMeasurements <= 0 || lg.UpperBound <= 0 || lg.LowerBound <= 0 || lg.Step <= 0 {
|
|
return errors.New("minimumMeasurements, upperbound, step, and lowerBound must be greater than 0")
|
|
}
|
|
if lg.LowerBound > lg.UpperBound {
|
|
return errors.New("upperbound must be greater than lowerbound")
|
|
}
|
|
return nil
|
|
}
|