Monday, 2 June 2014

Do comments affect compile time or form size?

A while ago, someone asked on whether it takes longer to compile a form that has a lot of comments in it than one that doesn't, and Theo Neesksens suggested that maybe I should take a look.  A colleague of mine emailed me the post and I filed it away to respond to when I had a moment.  Well, what can I say, I've been busy!  (And I forgot about it!)

There's an easy way to compile a form programmatically (so that I can wrap timing code around it) and that's using $ude, something like this...

  $result = $ude("compile","form","TEST_FORM")

First I selected an existing form with minimal comments, and compiled it a number of times, noting the size.  Then I added lots of comments and noted those times and sizes as well...

  • Original form (93526 bytes): 41.38, 44.84, 42.03 (average of 42.75 secs)
  • 1000 comment lines (93526 bytes): 44.92, 45.88, 46.61 (average of 45.80 secs)
  • 2000 comment lines (93526 bytes): 46.40, 44.34, 47.76 (average of 46.17 secs)
  • 3000 comment lines (93526 bytes): 47.28, 48.85, 49.31 (average of 48.48 secs)
  • 4000 comment lines (93526 bytes): 49.30, 49.25, 49.19 (average of 49.25 secs)
  • 5000 comment lines (93526 bytes): 49.39, 50.07, 49.96 (average of 49.81 secs)
  • 10000 comment lines (93526 bytes): 54.64, 53.98, 55.16 (average of 54.59 secs)

So as you can see, the size of the compiled form is always the same, so the comments are stripped out, and this process of striping out the comments does take some time.  

I'm not aware of a way to get the individual timings out for each phase, but it seems to me that the comments are removed during the first phase, as this seems to take slightly longer as more comments are added.

On a personal note, I think adding extra comments into your code is a good thing, if it makes it more readable, but better yet, have readable code that doesn't need many comments!  

Summary: Unless you put thousands of lines of comments in, it's not going to have much of an impact on your compile time, but it's certainly not going to have an impact on your compiled file size.

Thanks to Theo Neesksens and Mark R for pointing me in the direction of this one.


  1. Hi Rick,
    Thanks for continuing your blog on Uniface. Always fun to read.
    Theo's surname is actually Neeskens :-)
    Arjen van Vliet
    Uniface BV

  2. Thank you for the correction, I've sorted that now. And I'm glad you enjoy the blog, let me know if there's anything in particular you'd be interested in seeing in the future.

  3. Thank you very much Rik. An excellent analysis as always!