Documentation
¶
Index ¶
- Variables
- func GetTableTimeOut(v float64, s string, options *Options) string
- func MarkdownTable(counts []*Count, options *Options) (content string)
- func MarkdownTableByCounts(counts []*Count) (content string)
- func ToTimeStr(size int64) (v string)
- type Count
- type Item
- type ItemList
- type Metric
- func (this_ *Metric) DoCount()
- func (this_ *Metric) GetCount() (count *Count)
- func (this_ *Metric) GetSecondCounts() (counts []*Count)
- func (this_ *Metric) GewWorkerMetrics() (workerMetrics []*WorkerMetric)
- func (this_ *Metric) NewWorkerMetric(workerIndex int) (workerMetric *WorkerMetric)
- func (this_ *Metric) SetCountSecond(countSecond int) *Metric
- func (this_ *Metric) SetCountTop(countTop bool) *Metric
- func (this_ *Metric) SetOnCount(onCount func()) *Metric
- func (this_ *Metric) StartCount()
- func (this_ *Metric) StopCount()
- type Options
- type SecondItem
- type TableColumn
- type WorkerMetric
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Use4000 = 1000000 * 4000 Use3000 = 1000000 * 3000 Use2000 = 1000000 * 2000 Use1000 = 1000000 * 1000 Use500 = 1000000 * 500 Use200 = 1000000 * 200 Use100 = 1000000 * 100 )
View Source
var ( TableColumnName = &TableColumn{ Label: "名称", GetCol: func(count *Count, options *Options) (res string) { res = count.Name return }, } TableColumnTime = &TableColumn{ Label: "任务时间", GetCol: func(count *Count, options *Options) (res string) { if options.AddHtmlFormat { res = " %s <br>-<br> %s" } else { res = " %s - %s" } res = fmt.Sprintf(res, util.TimeFormat(time.UnixMilli(count.StartTime/int64(time.Millisecond)), "2006-01-02 15:04:05.000"), util.TimeFormat(time.UnixMilli(count.EndTime/int64(time.Millisecond)), "2006-01-02 15:04:05.000"), ) return }, } TableColumnCount = &TableColumn{ Label: "总/成功/失败", GetCol: func(count *Count, options *Options) (res string) { if options.AddHtmlFormat { res = "%d <br> <font color='green'>%d</font> <br> <font color='red'>%d</font>" } else { res = "%d / %d / %d" } res = fmt.Sprintf(res, count.Count, count.SuccessCount, count.ErrorCount) return }, } TableColumnTotalTime = &TableColumn{ Label: "任务用时", GetCol: func(count *Count, options *Options) (res string) { res = ToTimeStr(count.TotalTime / 1000000) return }, } TableColumnExecuteTime = &TableColumn{ Label: "执行用时", GetCol: func(count *Count, options *Options) (res string) { res = ToTimeStr(count.ExecuteTime / 1000000) return }, } TableColumnUseTime = &TableColumn{ Label: "累计用时", GetCol: func(count *Count, options *Options) (res string) { res = ToTimeStr(count.UseTime / 1000000) return }, } TableColumnTps = &TableColumn{ Label: "TPS", GetCol: func(count *Count, options *Options) (res string) { res = count.Tps return }, } TableColumnAvg = &TableColumn{ Label: "Avg", GetCol: func(count *Count, options *Options) (res string) { res = GetTableTimeOut(count.AvgValue, count.Avg, options) return }, } TableColumnMin = &TableColumn{ Label: "Min", GetCol: func(count *Count, options *Options) (res string) { res = GetTableTimeOut(float64(count.MinUseTime)/float64(time.Millisecond), count.Min, options) return }, } TableColumnMax = &TableColumn{ Label: "Max", GetCol: func(count *Count, options *Options) (res string) { res = GetTableTimeOut(float64(count.MaxUseTime)/float64(time.Millisecond), count.Max, options) return }, } TableColumnT50 = &TableColumn{ Label: "T50", GetCol: func(count *Count, options *Options) (res string) { res = GetTableTimeOut(util.StringToFloat64(count.T50), count.T50, options) return }, } TableColumnT80 = &TableColumn{ Label: "T80", GetCol: func(count *Count, options *Options) (res string) { res = GetTableTimeOut(util.StringToFloat64(count.T80), count.T80, options) return }, } TableColumnT90 = &TableColumn{ Label: "T90", GetCol: func(count *Count, options *Options) (res string) { res = GetTableTimeOut(util.StringToFloat64(count.T90), count.T90, options) return }, } TableColumnT99 = &TableColumn{ Label: "T99", GetCol: func(count *Count, options *Options) (res string) { res = GetTableTimeOut(util.StringToFloat64(count.T99), count.T99, options) return }, } TableColumnUse100 = &TableColumn{ Label: "100ms", GetCol: func(count *Count, options *Options) (res string) { if options.AddHtmlFormat { res = "%s <br> %d" } else { res = "%s / %d" } v := count.Use4000 + count.Use3000 + count.Use2000 + count.Use1000 + count.Use500 + count.Use200 + count.Use100 p := strconv.FormatFloat(float64(v)*100/float64(count.Count), 'f', 2, 64) res = fmt.Sprintf(res, p+"%", v) return }, } TableColumnUse200 = &TableColumn{ Label: "200ms", GetCol: func(count *Count, options *Options) (res string) { if options.AddHtmlFormat { res = "%s <br> %d" } else { res = "%s / %d" } v := count.Use4000 + count.Use3000 + count.Use2000 + count.Use1000 + count.Use500 + count.Use200 p := strconv.FormatFloat(float64(v)*100/float64(count.Count), 'f', 2, 64) res = fmt.Sprintf(res, p+"%", v) return }, } TableColumnUse500 = &TableColumn{ Label: "500ms", GetCol: func(count *Count, options *Options) (res string) { if options.AddHtmlFormat { res = "%s <br> %d" } else { res = "%s / %d" } v := count.Use4000 + count.Use3000 + count.Use2000 + count.Use1000 + count.Use500 p := strconv.FormatFloat(float64(v)*100/float64(count.Count), 'f', 2, 64) res = fmt.Sprintf(res, p+"%", v) return }, } TableColumnUse1000 = &TableColumn{ Label: "1000ms", GetCol: func(count *Count, options *Options) (res string) { if options.AddHtmlFormat { res = "%s <br> %d" } else { res = "%s / %d" } v := count.Use4000 + count.Use3000 + count.Use2000 + count.Use1000 p := strconv.FormatFloat(float64(v)*100/float64(count.Count), 'f', 2, 64) res = fmt.Sprintf(res, p+"%", v) return }, } TableColumnUse2000 = &TableColumn{ Label: "2000ms", GetCol: func(count *Count, options *Options) (res string) { if options.AddHtmlFormat { res = "%s <br> %d" } else { res = "%s / %d" } v := count.Use4000 + count.Use3000 + count.Use2000 p := strconv.FormatFloat(float64(v)*100/float64(count.Count), 'f', 2, 64) res = fmt.Sprintf(res, p+"%", v) return }, } TableColumnUse3000 = &TableColumn{ Label: "3000ms", GetCol: func(count *Count, options *Options) (res string) { if options.AddHtmlFormat { res = "%s <br> %d" } else { res = "%s / %d" } v := count.Use4000 + count.Use3000 p := strconv.FormatFloat(float64(v)*100/float64(count.Count), 'f', 2, 64) res = fmt.Sprintf(res, p+"%", v) return }, } TableColumnUse4000 = &TableColumn{ Label: "4000ms", GetCol: func(count *Count, options *Options) (res string) { if options.AddHtmlFormat { res = "%s <br> %d" } else { res = "%s / %d" } v := count.Use4000 p := strconv.FormatFloat(float64(v)*100/float64(count.Count), 'f', 2, 64) res = fmt.Sprintf(res, p+"%", v) return }, } )
View Source
var (
Second = int64(time.Second)
)
Functions ¶
func GetTableTimeOut ¶ added in v0.8.6
func MarkdownTable ¶ added in v0.6.9
func MarkdownTableByCounts ¶ added in v0.6.2
Types ¶
type Count ¶
type Count struct { Name string `json:"name"` StartTime int64 `json:"startTime"` // 纳秒 EndTime int64 `json:"endTime"` // 纳秒 Count int `json:"count"` SuccessCount int `json:"successCount"` ErrorCount int `json:"errorCount"` TotalTime int64 `json:"totalTime"` // 执行时长包括额外开销 从 最小 开始时间 到 最大结束时间 的时间差 纳秒 Total string `json:"total"` // 执行时长包括额外开销 毫秒 保留 2位小数 ExecuteTime int64 `json:"executeTime"` // 执行时长包括额外开销 从 最小 开始时间 到 最大结束时间 的时间差 纳秒 Execute string `json:"execute"` // 执行时长包括额外开销 毫秒 保留 2位小数 UseTime int64 `json:"useTime"` // 总调用时长 使用 所有项 的 耗时 相加 Use string `json:"use"` // 总调用时长 毫秒 保留 2位小数 Max string `json:"max"` // 最大时间 毫秒 保留 2位小数 MaxUseTime int `json:"maxTime"` // 最大时间 纳秒 Min string `json:"min"` // 最小时间 毫秒 保留 2位小数 MinUseTime int `json:"minTime"` // 最小时间 纳秒 Tps string `json:"tps"` // TPS 总次数 / 执行时长 秒 保留 2位小数 TpsValue float64 `json:"tpsValue"` // TPS 总次数 / 执行时长 秒 Avg string `json:"avg"` // 平均耗时 总调用时长 / 总次数 毫秒 保留 2位小数 AvgValue float64 `json:"avgValue"` // 平均耗时 总调用时长 / 总次数 毫秒 T50 string `json:"t50"` // TOP 50 表示 百分之 50 的调用超过这个时间 毫秒 保留 2位小数 T60 string `json:"t60"` // TOP 60 表示 百分之 60 的调用超过这个时间 毫秒 保留 2位小数 T70 string `json:"t70"` // TOP 70 表示 百分之 70 的调用超过这个时间 毫秒 保留 2位小数 T80 string `json:"t80"` // TOP 80 表示 百分之 80 的调用超过这个时间 毫秒 保留 2位小数 T90 string `json:"t90"` // TOP 90 表示 百分之 90 的调用超过这个时间 毫秒 保留 2位小数 T99 string `json:"t99"` // TOP 99 表示 百分之 99 的调用超过这个时间 毫秒 保留 2位小数 Use100 int64 `json:"use100"` // 大于 等于 100 毫秒 Use200 int64 `json:"use200"` // 大于 等于 200 毫秒 Use500 int64 `json:"use500"` // 大于 等于 500 毫秒 Use1000 int64 `json:"use1000"` // 大于 等于 1000 毫秒 Use2000 int64 `json:"use2000"` // 大于 等于 2000 毫秒 Use3000 int64 `json:"use3000"` // 大于 等于 3000 毫秒 Use4000 int64 `json:"use4000"` // 大于 等于 4000 毫秒 // contains filtered or unexported fields }
func CountCounts ¶ added in v0.6.6
func CountItems ¶
func WorkersCount ¶ added in v0.6.9
type Item ¶
type Metric ¶
type Metric struct {
// contains filtered or unexported fields
}
func (*Metric) GetSecondCounts ¶ added in v0.6.6
func (*Metric) GewWorkerMetrics ¶ added in v0.6.9
func (this_ *Metric) GewWorkerMetrics() (workerMetrics []*WorkerMetric)
func (*Metric) NewWorkerMetric ¶ added in v0.6.9
func (this_ *Metric) NewWorkerMetric(workerIndex int) (workerMetric *WorkerMetric)
func (*Metric) SetCountSecond ¶ added in v0.6.8
SetCountSecond 统计间隔秒 如 每秒统计 输入 1 默认 10 秒统计
func (*Metric) SetCountTop ¶ added in v0.6.9
SetCountTop 是否统计 T99 T90 T80等,高并发下 消耗内存将增加
func (*Metric) SetOnCount ¶ added in v0.6.9
SetOnCount 每次统计完成 调用该方法
func (*Metric) StartCount ¶ added in v0.6.6
func (this_ *Metric) StartCount()
type Options ¶ added in v0.6.9
type Options struct { AddHtmlFormat bool WarnUseTime int64 // 超过该时间 出现警告 为毫秒数 Columns []*TableColumn }
type SecondItem ¶ added in v0.6.9
type SecondItem struct {
// contains filtered or unexported fields
}
type TableColumn ¶ added in v0.8.6
type WorkerMetric ¶ added in v0.6.9
type WorkerMetric struct { WorkerIndex int `json:"workerIndex"` // 工作线程索引 用于并发线程下 每个线程的时间跨度计算 // contains filtered or unexported fields }
WorkerMetric 单线程 统计
func (*WorkerMetric) AddItem ¶ added in v0.7.9
func (this_ *WorkerMetric) AddItem(item *Item)
func (*WorkerMetric) NewItem ¶ added in v0.6.9
func (this_ *WorkerMetric) NewItem(startTime int64) (item *Item)
Click to show internal directories.
Click to hide internal directories.