Class: FastExists::Intelligence::Stats
- Inherits:
-
Object
- Object
- FastExists::Intelligence::Stats
- Defined in:
- lib/fast_exists/intelligence/stats.rb
Class Method Summary collapse
Class Method Details
.render(format: :console) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/fast_exists/intelligence/stats.rb', line 9 def self.render(format: :console) raw_stats = FastExists.stats.merge( active_backend: FastExists.configuration.backend, uptime_seconds: (FastExists.uptime rescue 0), sync_status: FastExists.configuration.auto_sync ? :active : :disabled ) case format.to_sym when :json JSON.pretty_generate(raw_stats) when :yaml raw_stats.transform_keys(&:to_s).to_yaml when :markdown to_markdown(raw_stats) else to_console(raw_stats) end end |
.to_console(s) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/fast_exists/intelligence/stats.rb', line 30 def self.to_console(s) <<~CONSOLE ================================================== ⚡ FastExists Runtime Statistics ================================================== Active Backend: #{s[:active_backend]} Memory Usage: #{s[:memory_usage] || 'N/A'} Capacity: #{s[:capacity] || 'N/A'} Occupancy: #{s[:occupancy] || 'N/A'} Bit Array Size: #{s[:bit_size] || 'N/A'} Hash Count: #{s[:hash_count] || 'N/A'} Inserted Elements: #{s[:inserted_items] || 0} Expected Elements: #{s[:expected_elements] || 0} Est. False Positive Rate: #{s[:estimated_false_positive_rate] || 0.0}% Actual False Positives: #{s[:false_positives]} Bloom Hits: #{s[:bloom_hits]} Bloom Misses: #{s[:bloom_misses]} Queries Avoided: #{s[:queries_avoided]} Database Lookups: #{s[:database_lookups]} Hit Ratio: #{(s[:hit_ratio] * 100).round(2)}% Miss Ratio: #{(s[:miss_ratio] * 100).round(2)}% Synchronization Status: #{s[:sync_status]} ================================================== CONSOLE end |
.to_markdown(s) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/fast_exists/intelligence/stats.rb', line 56 def self.to_markdown(s) <<~MARKDOWN # ⚡ FastExists Runtime Statistics | Metric | Value | |:---|:---| | **Active Backend** | `#{s[:active_backend]}` | | **Capacity** | #{s[:capacity] || 'N/A'} | | **Inserted Elements** | #{s[:inserted_items] || 0} | | **Queries Avoided** | **#{s[:queries_avoided]}** | | **Database Lookups** | #{s[:database_lookups]} | | **Bloom Hits** | #{s[:bloom_hits]} | | **Bloom Misses** | #{s[:bloom_misses]} | | **False Positives** | #{s[:false_positives]} | | **Hit Ratio** | #{(s[:hit_ratio] * 100).round(2)}% | | **Miss Ratio** | #{(s[:miss_ratio] * 100).round(2)}% | | **Est. FP Rate** | #{s[:estimated_false_positive_rate] || 0.0}% | | **Sync Status** | `#{s[:sync_status]}` | MARKDOWN end |