Module: A2A::Client::PerformanceTracker
- Included in:
- HttpClient
- Defined in:
- lib/a2a/client/performance_tracker.rb
Overview
Performance tracking functionality for HTTP clients
Instance Method Summary collapse
-
#initialize_performance_tracking ⇒ Object
Initialize performance tracking.
-
#performance_stats ⇒ Hash
Get performance statistics.
-
#record_request_performance(duration) ⇒ Object
Record request performance metrics.
-
#reset_performance_stats! ⇒ Object
Reset performance statistics.
Instance Method Details
#initialize_performance_tracking ⇒ Object
Initialize performance tracking
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/a2a/client/performance_tracker.rb', line 12 def initialize_performance_tracking @performance_stats = { requests_count: 0, total_time: 0.0, avg_response_time: 0.0, cache_hits: 0, cache_misses: 0 } @stats_mutex = Mutex.new end |
#performance_stats ⇒ Hash
Get performance statistics
27 28 29 |
# File 'lib/a2a/client/performance_tracker.rb', line 27 def performance_stats @stats_mutex.synchronize { @performance_stats.dup } end |
#record_request_performance(duration) ⇒ Object
Record request performance metrics
50 51 52 53 54 55 56 57 |
# File 'lib/a2a/client/performance_tracker.rb', line 50 def record_request_performance(duration) @stats_mutex.synchronize do @performance_stats[:requests_count] += 1 @performance_stats[:total_time] += duration @performance_stats[:avg_response_time] = @performance_stats[:total_time] / @performance_stats[:requests_count] end end |
#reset_performance_stats! ⇒ Object
Reset performance statistics
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/a2a/client/performance_tracker.rb', line 34 def reset_performance_stats! @stats_mutex.synchronize do @performance_stats = { requests_count: 0, total_time: 0.0, avg_response_time: 0.0, cache_hits: 0, cache_misses: 0 } end end |