Module: Xmi::Performance::Term
- Defined in:
- lib/xmi/performance/runner.rb
Overview
Pretty terminal formatting for benchmark output.
Constant Summary collapse
- CLEAR =
"\e[0m"- BOLD =
"\e[1m"- DIM =
"\e[2m"- RED =
"\e[31m"- GREEN =
"\e[32m"- YELLOW =
"\e[33m"- CYAN =
"\e[36m"- MAGENTA =
"\e[35m"- HL =
"─"- VL =
"│"- TL =
"┌"- TR =
"┐"- BL =
"└"- BR =
"┘"
Class Method Summary collapse
- .category(title, icon:, description:, failure_means:, compare_against: nil) ⇒ Object
- .env_info(ruby_version, platform) ⇒ Object
- .header(title, color: CYAN) ⇒ Object
- .sep(char: HL, width: 78) ⇒ Object
Class Method Details
.category(title, icon:, description:, failure_means:, compare_against: nil) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/xmi/performance/runner.rb', line 47 def self.category(title, icon:, description:, failure_means:, compare_against: nil) puts puts "#{CYAN}#{VL}#{CLEAR} #{BOLD}#{MAGENTA}#{icon} #{title}#{CLEAR}" puts puts " #{DIM}#{description}#{CLEAR}" puts if compare_against puts " #{CYAN}Comparing against:#{CLEAR} #{compare_against}" puts end puts " #{YELLOW}⚠️ Failure means:#{CLEAR} #{failure_means}" puts sep(width: 76) puts end |
.env_info(ruby_version, platform) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/xmi/performance/runner.rb', line 39 def self.env_info(ruby_version, platform) puts puts " #{DIM}Environment:#{CLEAR}" puts " #{VL} Ruby #{ruby_version} on #{platform}#{' ' * (60 - ruby_version.length - platform.length)}#{VL}" puts " #{DIM}#{BL}#{HL * 76}#{BR}#{CLEAR}" puts end |
.header(title, color: CYAN) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/xmi/performance/runner.rb', line 26 def self.header(title, color: CYAN) width = 78 line = HL * width puts puts "#{color}#{TL}#{line}#{TR}#{CLEAR}" puts "#{color}#{VL}#{CLEAR} #{BOLD}#{color}#{title}#{CLEAR}#{' ' * (width - title.length - 4)}#{color}#{VL}#{CLEAR}" puts "#{color}#{BL}#{line}#{BR}#{CLEAR}" end |