Debian Codegraph @

stress/v2/statement/response_time.go

raw symbols SCIP
1 package statement
2
3 import (
4 "time"
5 )
6
7 // ResponseTime is a struct that contains `Value`
8 // `Time` pairing.
9 type ResponseTime struct {
10 Value int
11 Time time.Time
12 }
13
14 // NewResponseTime returns a new response time
15 // with value `v` and time `time.Now()`.
16 func NewResponseTime(v int) ResponseTime {
17 r := ResponseTime{Value: v, Time: time.Now()}
18 return r
19 }
20
21 // ResponseTimes is a slice of response times
22 type ResponseTimes []ResponseTime
23
24 // Implements the `Len` method for the
25 // sort.Interface type
26 func (rs ResponseTimes) Len() int {
27 return len(rs)
28 }
29
30 // Implements the `Less` method for the
31 // sort.Interface type
32 func (rs ResponseTimes) Less(i, j int) bool {
33 return rs[i].Value < rs[j].Value
34 }
35
36 // Implements the `Swap` method for the
37 // sort.Interface type
38 func (rs ResponseTimes) Swap(i, j int) {
39 rs[i], rs[j] = rs[j], rs[i]
40 }