Class: RokuBuilder::Profiler
- Extended by:
- Plugin
- Defined in:
- lib/roku_builder/plugins/profiler.rb
Overview
Scene Graph Profiler
Class Method Summary collapse
Instance Method Summary collapse
- #devlog(options:) ⇒ Object
-
#profile(options:) ⇒ Object
Run the profiler commands.
- #sgperf(options:) ⇒ Object
Methods included from Plugin
commands, dependencies, parse_options
Methods inherited from Util
Constructor Details
This class inherits a constructor from RokuBuilder::Util
Class Method Details
.commands ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/roku_builder/plugins/profiler.rb', line 9 def self.commands { profile: {device: true}, sgperf: {device: true}, devlog: {device: true} } end |
.parse_options(parser:, options:) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/roku_builder/plugins/profiler.rb', line 17 def self.(parser:, options:) parser.separator "Commands:" parser.on("--profile COMMAND", "Run various profiler options") do |c| [:profile] = c end parser.on("--sgperf", "Run scenegraph profiler") do [:sgperf] = true end parser.on("--devlog FUNCTION [TYPE]", "Run scenegraph profiler") do |f, t| [:devlog] = t || "rendezvous" [:devlog_function] = f end end |
Instance Method Details
#devlog(options:) ⇒ Object
89 90 91 92 93 94 95 96 |
# File 'lib/roku_builder/plugins/profiler.rb', line 89 def devlog(options:) telnet_config ={ 'Host' => @roku_ip_address, 'Port' => 8080 } connection = Net::Telnet.new(telnet_config) connection.puts("enhanced_dev_log #{[:devlog]} #{[:devlog_function]}\n") end |
#profile(options:) ⇒ Object
Run the profiler commands
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/roku_builder/plugins/profiler.rb', line 33 def profile(options:) @connection = nil case [:profile].to_sym when :stats print_stats when :all print_all_nodes when :roots print_root_nodes when :images print_image_information when :memmory print_memmory_usage when :textures print_texture_information else print_nodes_by_id([:profile]) end @connection.close if @connection end |
#sgperf(options:) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/roku_builder/plugins/profiler.rb', line 54 def sgperf(options:) telnet_config ={ 'Host' => @roku_ip_address, 'Port' => 8080 } @connection = Net::Telnet.new(telnet_config) @connection.puts("sgperf clear\n") @connection.puts("sgperf start\n") start_reg = /thread/ end_reg = /#{SecureRandom.uuid}/ prev_lines = 0 begin while true lines = get_command_response(command: "sgperf report", start_reg: start_reg, end_reg: end_reg, ignore_warnings: true) results = [] lines.each do |line| match = /thread node calls: create\s*(\d*) \+ op\s*(\d*)\s*@\s*(\d*\.\d*)% rendezvous/.match(line) results.push([match[1].to_i, match[2].to_i, match[3].to_f]) end print "\r" + ("\e[A\e[K"*prev_lines) prev_lines = 0 results.each_index do |i| line = results[i] if line[0] > 0 or line[1] > 0 or [:verbose] prev_lines += 1 puts "Thread #{i}: c:#{line[0]} u:#{line[1]} r:#{line[2]}%" end end end rescue SystemExit, Interrupt @connection.close if @connection end end |