lib/faml/stats.rb in faml-0.4.2 vs lib/faml/stats.rb in faml-0.5.0

- old
+ new

@@ -11,10 +11,11 @@ :static_id_or_class_attribute_count, :dynamic_attribute_count, :dynamic_attribute_with_data_count, :dynamic_attribute_with_newline_count, :ruby_attribute_count, + :object_reference_count, :multi_attribute_count, :ast_types ) do def initialize(*) super @@ -97,10 +98,15 @@ raise "InternalError: Unknown ast #{ast.class}: #{ast.inspect}" end end def collect_attribute_info(info, ast) + if ast.object_ref + info.object_reference_count += 1 + return + end + if ast.attributes.empty? if ast.static_class.empty? && ast.static_id.empty? info.empty_attribute_count += 1 else info.static_id_or_class_attribute_count += 1 @@ -131,20 +137,21 @@ end def report_attribute_stats(info) static = info.static_attribute_count dynamic = info.dynamic_attribute_count + info.dynamic_attribute_with_data_count + info.dynamic_attribute_with_newline_count - ruby = info.ruby_attribute_count + info.multi_attribute_count + ruby = info.ruby_attribute_count + info.multi_attribute_count + info.object_reference_count total = static + dynamic + ruby puts 'Attribute stats' printf(" Empty attributes: %d\n", info.empty_attribute_count) printf(" Attributes with id or class only: %d\n", info.static_id_or_class_attribute_count) printf(" Static attributes: %d (%.2f%%)\n", static, static * 100.0 / total) printf(" Dynamic attributes: %d (%.2f%%)\n", dynamic, dynamic * 100.0 / total) printf(" with data: %d\n", info.dynamic_attribute_with_data_count) printf(" with newline: %d\n", info.dynamic_attribute_with_newline_count) printf(" Ruby attributes: %d (%.2f%%)\n", ruby, ruby * 100.0 / total) printf(" with multiple arguments: %d\n", info.multi_attribute_count) + printf(" with object reference: %d\n", info.object_reference_count) end def report_ast_stats(info) total = info.ast_types.values.inject(0, :+) puts 'AST stats'