From 851bedfd9755ea84e89b440237d39084ff891209 Mon Sep 17 00:00:00 2001 From: Alexandre Terrasa Date: Tue, 22 Jan 2013 12:47:30 -0500 Subject: [PATCH] nitg-s: Added stats output for compilation process Signed-off-by: Alexandre Terrasa --- src/separate_compiler.nit | 38 +++++++++++++++++++++++++++++++++++++ src/separate_erasure_compiler.nit | 22 +++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/src/separate_compiler.nit b/src/separate_compiler.nit index 8ea3850..4f5e920 100644 --- a/src/separate_compiler.nit +++ b/src/separate_compiler.nit @@ -47,6 +47,9 @@ redef class ToolContext # --generic-resolution-tree var opt_generic_tree: OptionBool = new OptionBool("Use tree representation for live generic types instead of flattened representation", "--generic-resolution-tree") + # --generic-resolution-tree + var opt_typing_table_metrics: OptionBool = new OptionBool("Enable static size measuring of tables used for typing and resolution", "--typing-table-metrics") + redef init do super @@ -59,6 +62,7 @@ redef class ToolContext self.option_context.add_option(self.opt_phmod_typing) self.option_context.add_option(self.opt_phand_typing) self.option_context.add_option(self.opt_generic_tree) + self.option_context.add_option(self.opt_typing_table_metrics) end end @@ -890,6 +894,40 @@ class SeparateCompiler end redef fun new_visitor do return new SeparateCompilerVisitor(self) + + redef fun display_stats + do + super + if self.modelbuilder.toolcontext.opt_typing_table_metrics.value then + display_sizes + end + end + + fun display_sizes + do + print "# size of tables" + print "\trs size\trs hole\tst size\tst hole" + var rt_table = 0 + var rt_holes = 0 + var st_table = 0 + var st_holes = 0 + var rtables = unanchored_types_tables + if rtables != null then + for unanch, table in rtables do + rt_table += table.length + for e in table do if e == null then rt_holes += 1 + end + end + + var ttables = type_tables + if ttables != null then + for t, table in ttables do + st_table += table.length + for e in table do if e == null then st_holes += 1 + end + end + print "\t{rt_table}\t{rt_holes}\t{st_table}\t{st_holes}" + end end # The C function associated to a methoddef separately compiled diff --git a/src/separate_erasure_compiler.nit b/src/separate_erasure_compiler.nit index 2d64aa0..9ccc108 100644 --- a/src/separate_erasure_compiler.nit +++ b/src/separate_erasure_compiler.nit @@ -316,6 +316,28 @@ class SeparateErasureCompiler end redef fun new_visitor do return new SeparateErasureCompilerVisitor(self) + + redef fun display_sizes + do + print "# size of tables" + print "\trs size\trs hole\tst size\tst hole" + var rt_table = 0 + var rt_holes = 0 + var st_table = 0 + var st_holes = 0 + var rtables = vt_tables + for unanch, table in rtables do + rt_table += table.length + for e in table do if e == null then rt_holes += 1 + end + + var ttables = class_tables + for t, table in ttables do + st_table += table.length + for e in table do if e == null then st_holes += 1 + end + print "\t{rt_table}\t{rt_holes}\t{st_table}\t{st_holes}" + end end class SeparateErasureCompilerVisitor -- 1.7.9.5