Class: Vernier::ParsedProfile
- Inherits:
-
Object
- Object
- Vernier::ParsedProfile
- Defined in:
- lib/vernier/parsed_profile.rb
Defined Under Namespace
Classes: StackTable, Thread
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data) ⇒ ParsedProfile
constructor
A new instance of ParsedProfile.
- #main_thread ⇒ Object
- #threads ⇒ Object
Constructor Details
#initialize(data) ⇒ ParsedProfile
Returns a new instance of ParsedProfile.
87 88 89 |
# File 'lib/vernier/parsed_profile.rb', line 87 def initialize(data) @data = data end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
86 87 88 |
# File 'lib/vernier/parsed_profile.rb', line 86 def data @data end |
Class Method Details
.read_file(filename) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/vernier/parsed_profile.rb', line 8 def self.read_file(filename) # Print the inverted tree from a Vernier profile is_gzip = File.binread(filename, 2) == "\x1F\x8B".b # check for gzip header json = if is_gzip require "zlib" Zlib::GzipReader.open(filename) { |gz| gz.read } else File.read filename end info = JSON.load json new(info) end |
Instance Method Details
#main_thread ⇒ Object
98 99 100 |
# File 'lib/vernier/parsed_profile.rb', line 98 def main_thread threads.detect(&:main_thread?) end |
#threads ⇒ Object
91 92 93 94 95 96 |
# File 'lib/vernier/parsed_profile.rb', line 91 def threads @threads ||= @data["threads"].map do |thread_data| Thread.new(thread_data) end end |