Class: Contrek::Cpp::CPPResult
- Inherits:
-
Object
- Object
- Contrek::Cpp::CPPResult
- Includes:
- Shared::Result
- Defined in:
- lib/contrek/cpp/cpp_result.rb
Class Method Summary collapse
Instance Method Summary collapse
Methods included from Shared::Result
Class Method Details
.to_numpy(polygons_data) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/contrek/cpp/cpp_result.rb', line 38 def self.to_numpy(polygons_data) polygons_data.map do |poly| {outer: poly[:outer].flat_map { |p| [p[:x], p[:y]] }, inner: (poly[:inner] || []).map { |hole| hole.flat_map { |p| [p[:x], p[:y]] } }, bounds: poly[:bounds]} end end |
.to_points(flat_polygon) ⇒ Object
34 35 36 |
# File 'lib/contrek/cpp/cpp_result.rb', line 34 def self.to_points(flat_polygon) flat_polygon.each_slice(2).map { |x, y| {x: x, y: y} } end |
Instance Method Details
#metadata=(map) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/contrek/cpp/cpp_result.rb', line 12 def (map) @metadata_storage = { width: 0, height: 0, benchmarks: {}, treemap: [] }.merge(map) end |
#points ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/contrek/cpp/cpp_result.rb', line 21 def points raw_list = polygons.to_a @to_points ||= raw_list.map do |polygon| {bounds: (polygon[:bounds] if polygon.key?(:bounds)), outer: self.class.to_points(polygon[:outer]), inner: polygon[:inner].map { |s| self.class.to_points(s) }}.compact end end |
#polygons=(list) ⇒ Object
8 9 10 |
# File 'lib/contrek/cpp/cpp_result.rb', line 8 def polygons=(list) @polygons_storage = list end |
#total_time ⇒ Object
30 31 32 |
# File 'lib/contrek/cpp/cpp_result.rb', line 30 def total_time [:benchmarks].values.sum end |