@@ -15,6 +15,12 @@ public class InfoViewManager
1515 private string dEVID = "" ;
1616 private string apiUrl = "" ;
1717
18+ private int completedRequests = 0 ;
19+ private TimeSpan minResponseTime = TimeSpan . MaxValue ;
20+ private TimeSpan maxResponseTime = TimeSpan . Zero ;
21+ private TimeSpan totalResponseTime = TimeSpan . Zero ;
22+ private TimeSpan avgResponseTime = TimeSpan . Zero ;
23+
1824 public InfoViewManager ( RichTextBox textBox )
1925 {
2026 this . textBox = textBox ;
@@ -43,6 +49,32 @@ public void Update(Gateway? gateway)
4349 Print ( ) ;
4450 }
4551
52+ public void ReportApiCall ( TimeSpan elapsed )
53+ {
54+ completedRequests ++ ;
55+ totalResponseTime += elapsed ;
56+
57+ if ( elapsed < minResponseTime )
58+ minResponseTime = elapsed ;
59+
60+ if ( elapsed > maxResponseTime )
61+ maxResponseTime = elapsed ;
62+
63+ avgResponseTime = totalResponseTime / completedRequests ;
64+
65+ Print ( ) ;
66+ }
67+
68+ public void ClearApiStatsInfo ( )
69+ {
70+ completedRequests = 0 ;
71+ minResponseTime = TimeSpan . MaxValue ;
72+ maxResponseTime = TimeSpan . Zero ;
73+ totalResponseTime = TimeSpan . Zero ;
74+ avgResponseTime = TimeSpan . Zero ;
75+ Print ( ) ;
76+ }
77+
4678 public void ClearOrganisationInfo ( )
4779 {
4880 apiUrl = "" ;
@@ -71,11 +103,19 @@ public void ClearGatewayInfo()
71103
72104 private void Print ( )
73105 {
106+ string compl = this . completedRequests . ToString ( ) ;
107+ string min = minResponseTime != TimeSpan . MaxValue ? $ "{ minResponseTime . TotalMilliseconds : F0} ms" : "-" ;
108+ string max = maxResponseTime != TimeSpan . Zero ? $ "{ maxResponseTime . TotalMilliseconds : F0} ms" : "-" ;
109+ string avg = completedRequests > 0 ? $ "{ avgResponseTime . TotalMilliseconds : F0} ms" : "-" ;
110+
74111 textBox . Text = @$ "Api { apiUrl }
75112Host { host }
76113IST COM TRG SID DEVID
77114{ iST . PadRight ( 7 ) } { cOM . PadRight ( 7 ) } { tRG . PadRight ( 7 ) } { sID . PadRight ( 7 ) } { dEVID . PadRight ( 7 ) }
115+ Calls Min Max Avg
116+ { compl . PadRight ( 7 ) } { min . PadRight ( 7 ) } { max . PadRight ( 7 ) } { avg . PadRight ( 7 ) }
78117" ;
118+
79119 }
80120 }
81121}
0 commit comments