[m-dev.] source code metrics

Fergus Henderson fjh at cs.mu.OZ.AU
Fri May 12 18:10:40 AEST 2000


Hi,

I just noticed that we just reached the 200 thousand lines of source
(KLOS) mark for the Mercury source files in the compiler directory.
Of that, 30% is comments or whitespace (14% comments + 16% whitespace)
and the remaining 70% is code (13% declarations + 57% clauses).
If you ignore the comments and whitespace,
it's 140 thousand lines of code (KLOC).

The new MLDS back-end is 11.5 KLOS / 6.1 KLOC:
47% non-code (26% comments + 21% whitespace) and
53% code (11% declarations + 42% code).
As you can see the comment ratio of 1:2 comments:code is much better
than the 1:5 ratio for the compiler as a whole ;-)
(Note that for the purposes of these stats, lines containing only `%'
or `%---...---%' are counted as whitespace, not as comments.)

This compares with about 21.5 KLOS / 14.7 KLOC for the base part of
the LLDS back-end, with a comments:code ratio of 1:4.6.

I didn't count the parts of the LLDS back-end which implement things
that should eventually also be implemented for the MLDS back-end, e.g.
middle recursion optimization and the various specialized switch
generation modules.  They're another 3.1 KLOS / 2.3 KLOC.

On the other hand, the LLDS back-end supports debugging, trailing,
heap reclamation on failure, and accurate GC; the MLDS back-end
doesn't yet support any of those.  I didn't count trace.m (0.9 KLOS /
0.6 KLOC) in the counts for the LLDS back-end, but much of the code to
support debugging is spread throughout the LLDS code generator.

Of course, a major simplification of the MLDS back-end is that we can
for the most part rely on the C compiler to do a reasonable job of
optimization.  If we count the LLDS optimization phases as part of the
LLDS back-end, that adds a very large amount: another 12.7 KLOS / 9.8
KLOC (with comments:code ratio 1:8.7).

P.S. Here's the raw data for the KLOS counts.  The KLOC counts and the
percentages and ratios were obtained using compiler/source_stats.awk
on the same sets of files.

	MLDS back-end:
	    657 ml_call_gen.m
	   2314 ml_code_gen.m
	   1422 ml_code_util.m
	   1326 mlds.m
	   2081 mlds_to_c.m
	   1335 ml_elim_nested.m
	    492 ml_tailcall.m
	   1219 ml_unify_gen.m
	    614 rtti_to_mlds.m
	  11460 total

	LLDS back-end code generator:
	    188 arg_info.m
	    831 call_gen.m
	   1920 code_exprn.m
	    996 code_gen.m
	   3442 code_info.m
	    824 code_util.m
	     67 commit_gen.m
	    314 disj_gen.m
	    398 follow_code.m
	    356 follow_vars.m
	    360 ite_gen.m
	    620 live_vars.m
	   1188 liveness.m
	    116 ll_pseudo_type_info.m
	   1333 llds.m
	    359 llds_common.m
	   4332 llds_out.m
	    283 par_conj_gen.m
	   1170 pragma_c_gen.m
	    508 saved_vars.m
	    442 store_alloc.m
	    354 switch_gen.m
	    217 transform_llds.m
	    926 unify_gen.m
	  21544 total

	LLDS back-end code generation optimizations:
	    262 dense_switch.m
	    523 lookup_switch.m
	    585 middle_rec.m
	    356 string_switch.m
	   1356 tag_switch.m
	   3082 total

	LLDS back-end low-level optimizations:
	    154 basic_block.m
	     81 delay_slot.m
	    796 dupelim.m
	   1244 frameopt.m
	    155 labelopt.m
	    519 livemap.m
	    375 optimize.m
	    314 peephole.m
	   1215 value_number.m
	    953 vn_block.m
	    403 vn_cost.m
	    581 vn_debug.m
	    451 vn_filter.m
	   1197 vn_flush.m
	    368 vn_livemap.m
	   1004 vn_order.m
	    501 vn_table.m
	    245 vn_temploc.m
	    212 vn_type.m
	   1390 vn_util.m
	    511 vn_verify.m
	  12669 total

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list