@@ -72,12 +72,12 @@ impl GraphData {
72
72
}
73
73
74
74
/// Record requests per second metric.
75
- pub ( crate ) fn record_requests_per_second ( & mut self , key : String , second : usize ) {
76
- if !self . requests_per_second . contains_key ( & key) {
75
+ pub ( crate ) fn record_requests_per_second ( & mut self , key : & str , second : usize ) {
76
+ if !self . requests_per_second . contains_key ( key) {
77
77
self . requests_per_second
78
- . insert ( key. clone ( ) , TimeSeries :: new ( ) ) ;
78
+ . insert ( key. to_string ( ) , TimeSeries :: new ( ) ) ;
79
79
}
80
- let data = self . requests_per_second . get_mut ( & key) . unwrap ( ) ;
80
+ let data = self . requests_per_second . get_mut ( key) . unwrap ( ) ;
81
81
data. increase ( second, 1 ) ;
82
82
83
83
debug ! (
@@ -88,12 +88,12 @@ impl GraphData {
88
88
}
89
89
90
90
/// Record errors per second metric.
91
- pub ( crate ) fn record_errors_per_second ( & mut self , key : String , second : usize ) {
92
- if !self . errors_per_second . contains_key ( & key) {
91
+ pub ( crate ) fn record_errors_per_second ( & mut self , key : & str , second : usize ) {
92
+ if !self . errors_per_second . contains_key ( key) {
93
93
self . errors_per_second
94
- . insert ( key. clone ( ) , TimeSeries :: new ( ) ) ;
94
+ . insert ( key. to_string ( ) , TimeSeries :: new ( ) ) ;
95
95
}
96
- let data = self . errors_per_second . get_mut ( & key) . unwrap ( ) ;
96
+ let data = self . errors_per_second . get_mut ( key) . unwrap ( ) ;
97
97
data. increase ( second, 1 ) ;
98
98
99
99
debug ! (
@@ -959,15 +959,15 @@ mod test {
959
959
let mut graph = GraphData :: new ( ) ;
960
960
assert_eq ! ( graph. requests_per_second. len( ) , 0 ) ;
961
961
962
- graph. record_requests_per_second ( "GET /" . to_string ( ) , 0 ) ;
963
- graph. record_requests_per_second ( "GET /" . to_string ( ) , 0 ) ;
964
- graph. record_requests_per_second ( "GET /" . to_string ( ) , 0 ) ;
965
- graph. record_requests_per_second ( "GET /" . to_string ( ) , 1 ) ;
966
- graph. record_requests_per_second ( "GET /" . to_string ( ) , 2 ) ;
967
- graph. record_requests_per_second ( "GET /" . to_string ( ) , 2 ) ;
968
- graph. record_requests_per_second ( "GET /" . to_string ( ) , 2 ) ;
969
- graph. record_requests_per_second ( "GET /" . to_string ( ) , 2 ) ;
970
- graph. record_requests_per_second ( "GET /" . to_string ( ) , 2 ) ;
962
+ graph. record_requests_per_second ( "GET /" , 0 ) ;
963
+ graph. record_requests_per_second ( "GET /" , 0 ) ;
964
+ graph. record_requests_per_second ( "GET /" , 0 ) ;
965
+ graph. record_requests_per_second ( "GET /" , 1 ) ;
966
+ graph. record_requests_per_second ( "GET /" , 2 ) ;
967
+ graph. record_requests_per_second ( "GET /" , 2 ) ;
968
+ graph. record_requests_per_second ( "GET /" , 2 ) ;
969
+ graph. record_requests_per_second ( "GET /" , 2 ) ;
970
+ graph. record_requests_per_second ( "GET /" , 2 ) ;
971
971
assert_eq ! (
972
972
graph. requests_per_second. get( "GET /" ) . unwrap( ) . data. len( ) ,
973
973
3
@@ -976,13 +976,13 @@ mod test {
976
976
assert_eq ! ( graph. requests_per_second. get( "GET /" ) . unwrap( ) . data[ 1 ] , 1 ) ;
977
977
assert_eq ! ( graph. requests_per_second. get( "GET /" ) . unwrap( ) . data[ 2 ] , 5 ) ;
978
978
979
- graph. record_requests_per_second ( "GET /" . to_string ( ) , 100 ) ;
980
- graph. record_requests_per_second ( "GET /" . to_string ( ) , 100 ) ;
981
- graph. record_requests_per_second ( "GET /" . to_string ( ) , 100 ) ;
982
- graph. record_requests_per_second ( "GET /" . to_string ( ) , 0 ) ;
983
- graph. record_requests_per_second ( "GET /" . to_string ( ) , 1 ) ;
984
- graph. record_requests_per_second ( "GET /" . to_string ( ) , 2 ) ;
985
- graph. record_requests_per_second ( "GET /" . to_string ( ) , 5 ) ;
979
+ graph. record_requests_per_second ( "GET /" , 100 ) ;
980
+ graph. record_requests_per_second ( "GET /" , 100 ) ;
981
+ graph. record_requests_per_second ( "GET /" , 100 ) ;
982
+ graph. record_requests_per_second ( "GET /" , 0 ) ;
983
+ graph. record_requests_per_second ( "GET /" , 1 ) ;
984
+ graph. record_requests_per_second ( "GET /" , 2 ) ;
985
+ graph. record_requests_per_second ( "GET /" , 5 ) ;
986
986
assert_eq ! (
987
987
graph. requests_per_second. get( "GET /" ) . unwrap( ) . data. len( ) ,
988
988
101
@@ -1001,11 +1001,11 @@ mod test {
1001
1001
) ;
1002
1002
}
1003
1003
1004
- graph. record_requests_per_second ( "GET /user" . to_string ( ) , 0 ) ;
1005
- graph. record_requests_per_second ( "GET /user" . to_string ( ) , 1 ) ;
1006
- graph. record_requests_per_second ( "GET /user" . to_string ( ) , 1 ) ;
1007
- graph. record_requests_per_second ( "GET /" . to_string ( ) , 2 ) ;
1008
- graph. record_requests_per_second ( "GET /" . to_string ( ) , 5 ) ;
1004
+ graph. record_requests_per_second ( "GET /user" , 0 ) ;
1005
+ graph. record_requests_per_second ( "GET /user" , 1 ) ;
1006
+ graph. record_requests_per_second ( "GET /user" , 1 ) ;
1007
+ graph. record_requests_per_second ( "GET /" , 2 ) ;
1008
+ graph. record_requests_per_second ( "GET /" , 5 ) ;
1009
1009
assert_eq ! (
1010
1010
graph
1011
1011
. requests_per_second
@@ -1042,11 +1042,11 @@ mod test {
1042
1042
) ;
1043
1043
}
1044
1044
1045
- graph. record_requests_per_second ( "GET /user" . to_string ( ) , 100 ) ;
1046
- graph. record_requests_per_second ( "GET /user" . to_string ( ) , 0 ) ;
1047
- graph. record_requests_per_second ( "GET /user" . to_string ( ) , 1 ) ;
1048
- graph. record_requests_per_second ( "GET /" . to_string ( ) , 0 ) ;
1049
- graph. record_requests_per_second ( "GET /" . to_string ( ) , 1 ) ;
1045
+ graph. record_requests_per_second ( "GET /user" , 100 ) ;
1046
+ graph. record_requests_per_second ( "GET /user" , 0 ) ;
1047
+ graph. record_requests_per_second ( "GET /user" , 1 ) ;
1048
+ graph. record_requests_per_second ( "GET /" , 0 ) ;
1049
+ graph. record_requests_per_second ( "GET /" , 1 ) ;
1050
1050
assert_eq ! (
1051
1051
graph
1052
1052
. requests_per_second
@@ -1100,27 +1100,27 @@ mod test {
1100
1100
let mut graph = GraphData :: new ( ) ;
1101
1101
assert_eq ! ( graph. errors_per_second. len( ) , 0 ) ;
1102
1102
1103
- graph. record_errors_per_second ( "GET /" . to_string ( ) , 0 ) ;
1104
- graph. record_errors_per_second ( "GET /" . to_string ( ) , 0 ) ;
1105
- graph. record_errors_per_second ( "GET /" . to_string ( ) , 0 ) ;
1106
- graph. record_errors_per_second ( "GET /" . to_string ( ) , 1 ) ;
1107
- graph. record_errors_per_second ( "GET /" . to_string ( ) , 2 ) ;
1108
- graph. record_errors_per_second ( "GET /" . to_string ( ) , 2 ) ;
1109
- graph. record_errors_per_second ( "GET /" . to_string ( ) , 2 ) ;
1110
- graph. record_errors_per_second ( "GET /" . to_string ( ) , 2 ) ;
1111
- graph. record_errors_per_second ( "GET /" . to_string ( ) , 2 ) ;
1103
+ graph. record_errors_per_second ( "GET /" , 0 ) ;
1104
+ graph. record_errors_per_second ( "GET /" , 0 ) ;
1105
+ graph. record_errors_per_second ( "GET /" , 0 ) ;
1106
+ graph. record_errors_per_second ( "GET /" , 1 ) ;
1107
+ graph. record_errors_per_second ( "GET /" , 2 ) ;
1108
+ graph. record_errors_per_second ( "GET /" , 2 ) ;
1109
+ graph. record_errors_per_second ( "GET /" , 2 ) ;
1110
+ graph. record_errors_per_second ( "GET /" , 2 ) ;
1111
+ graph. record_errors_per_second ( "GET /" , 2 ) ;
1112
1112
assert_eq ! ( graph. errors_per_second. get( "GET /" ) . unwrap( ) . data. len( ) , 3 ) ;
1113
1113
assert_eq ! ( graph. errors_per_second. get( "GET /" ) . unwrap( ) . data[ 0 ] , 3 ) ;
1114
1114
assert_eq ! ( graph. errors_per_second. get( "GET /" ) . unwrap( ) . data[ 1 ] , 1 ) ;
1115
1115
assert_eq ! ( graph. errors_per_second. get( "GET /" ) . unwrap( ) . data[ 2 ] , 5 ) ;
1116
1116
1117
- graph. record_errors_per_second ( "GET /" . to_string ( ) , 100 ) ;
1118
- graph. record_errors_per_second ( "GET /" . to_string ( ) , 100 ) ;
1119
- graph. record_errors_per_second ( "GET /" . to_string ( ) , 100 ) ;
1120
- graph. record_errors_per_second ( "GET /" . to_string ( ) , 0 ) ;
1121
- graph. record_errors_per_second ( "GET /" . to_string ( ) , 1 ) ;
1122
- graph. record_errors_per_second ( "GET /" . to_string ( ) , 2 ) ;
1123
- graph. record_errors_per_second ( "GET /" . to_string ( ) , 5 ) ;
1117
+ graph. record_errors_per_second ( "GET /" , 100 ) ;
1118
+ graph. record_errors_per_second ( "GET /" , 100 ) ;
1119
+ graph. record_errors_per_second ( "GET /" , 100 ) ;
1120
+ graph. record_errors_per_second ( "GET /" , 0 ) ;
1121
+ graph. record_errors_per_second ( "GET /" , 1 ) ;
1122
+ graph. record_errors_per_second ( "GET /" , 2 ) ;
1123
+ graph. record_errors_per_second ( "GET /" , 5 ) ;
1124
1124
assert_eq ! (
1125
1125
graph. errors_per_second. get( "GET /" ) . unwrap( ) . data. len( ) ,
1126
1126
101
0 commit comments