wp
This commit is contained in:
@@ -7,7 +7,7 @@ import (
|
||||
"os"
|
||||
"time"
|
||||
|
||||
diploma "gordenko.dev/dima/qb"
|
||||
"gordenko.dev/dima/qb"
|
||||
"gordenko.dev/dima/qb/client"
|
||||
"gordenko.dev/dima/qb/proto"
|
||||
)
|
||||
@@ -15,12 +15,12 @@ import (
|
||||
// METRICS INFO
|
||||
|
||||
type MetricInfo struct {
|
||||
MetricID uint32 `json:"metricID"`
|
||||
MetricType diploma.MetricType `json:"metricType"`
|
||||
FracDigits int `json:"fracDigits"`
|
||||
Since int64 `json:"since"`
|
||||
Until int64 `json:"until"`
|
||||
Qty int `json:"qty"`
|
||||
MetricID uint32 `json:"metricID"`
|
||||
MetricType qb.MetricType `json:"metricType"`
|
||||
FracDigits int `json:"fracDigits"`
|
||||
Since int64 `json:"since"`
|
||||
Until int64 `json:"until"`
|
||||
Qty int `json:"qty"`
|
||||
}
|
||||
|
||||
func readMetricInfo(fileName string) (list []MetricInfo, err error) {
|
||||
@@ -42,12 +42,12 @@ type QueryRecipe struct {
|
||||
RangeCode int
|
||||
Since uint32
|
||||
Until uint32
|
||||
GroupBy diploma.GroupBy
|
||||
GroupBy qb.GroupBy
|
||||
}
|
||||
|
||||
type RandomQueryGenerator struct {
|
||||
metrics []MetricInfo
|
||||
groupByOptions []diploma.GroupBy
|
||||
groupByOptions []qb.GroupBy
|
||||
listCurrentValuesProbability int
|
||||
listPeriodsProbability int
|
||||
timeRangeProbDistribution []int
|
||||
@@ -86,10 +86,10 @@ func NewRandomQueryGenerator(opt RandomQueryGeneratorOptions) *RandomQueryGenera
|
||||
|
||||
return &RandomQueryGenerator{
|
||||
metrics: opt.Metrics,
|
||||
groupByOptions: []diploma.GroupBy{
|
||||
diploma.GroupByHour,
|
||||
diploma.GroupByDay,
|
||||
diploma.GroupByMonth,
|
||||
groupByOptions: []qb.GroupBy{
|
||||
qb.GroupByHour,
|
||||
qb.GroupByDay,
|
||||
qb.GroupByMonth,
|
||||
},
|
||||
listCurrentValuesProbability: opt.ListCurrentValuesProbability,
|
||||
listPeriodsProbability: opt.ListPeriodsProbability,
|
||||
@@ -108,7 +108,7 @@ func (s *RandomQueryGenerator) GetQueryRecipe() QueryRecipe {
|
||||
Method: listCurrentValues,
|
||||
}
|
||||
} else {
|
||||
if metric.MetricType == diploma.Cumulative {
|
||||
if metric.MetricType == qb.Cumulative {
|
||||
num = rand.Intn(100)
|
||||
if num < s.listPeriodsProbability {
|
||||
groupBy := s.groupByOptions[rand.Intn(len(s.groupByOptions))]
|
||||
@@ -118,10 +118,10 @@ func (s *RandomQueryGenerator) GetQueryRecipe() QueryRecipe {
|
||||
maxDays = 7
|
||||
)
|
||||
|
||||
if groupBy == diploma.GroupByDay {
|
||||
if groupBy == qb.GroupByDay {
|
||||
minDays = 1
|
||||
maxDays = 30
|
||||
} else if groupBy == diploma.GroupByMonth {
|
||||
} else if groupBy == qb.GroupByMonth {
|
||||
minDays = 1
|
||||
maxDays = 30
|
||||
}
|
||||
@@ -164,10 +164,10 @@ func (s *RandomQueryGenerator) GetQueryRecipe() QueryRecipe {
|
||||
maxDays = 7
|
||||
)
|
||||
|
||||
if groupBy == diploma.GroupByDay {
|
||||
if groupBy == qb.GroupByDay {
|
||||
minDays = 1
|
||||
maxDays = 30
|
||||
} else if groupBy == diploma.GroupByMonth {
|
||||
} else if groupBy == qb.GroupByMonth {
|
||||
minDays = 1
|
||||
maxDays = 30
|
||||
}
|
||||
@@ -350,7 +350,7 @@ func execQuery(conn *client.Connection, queryGenerator *RandomQueryGenerator, st
|
||||
Day: until.Day(),
|
||||
},
|
||||
GroupBy: recipe.GroupBy,
|
||||
AggregateFuncs: diploma.AggregateMin | diploma.AggregateMax | diploma.AggregateAvg,
|
||||
AggregateFuncs: qb.AggregateMin | qb.AggregateMax | qb.AggregateAvg,
|
||||
})
|
||||
elapsedTime = time.Since(t1)
|
||||
stat.ElapsedTime += elapsedTime
|
||||
|
||||
@@ -203,7 +203,7 @@ const mainUsage = `Usage:
|
||||
|
||||
`
|
||||
|
||||
const helpMessage = `Diploma project. Load test. Version: 1.0
|
||||
const helpMessage = `Gordenko project. Load test. Version: 1.0
|
||||
created by Dmytro Gordenko, 1.e4.kc6@gmail.com
|
||||
`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user