[m-rev.] for post-commit review: cords in the deep_profiler

Ian MacLarty maclarty at csse.unimelb.edu.au
Thu Aug 7 10:59:58 AEST 2008


On Tue, Aug 5, 2008 at 9:18 PM, Paul Bone <pbone at csse.unimelb.edu.au> wrote:
> On Mon, Aug 05, 2008 at 01:16:40PM +1000, Zoltan Somogyi wrote:
>> Convert Paul's new code to use cords of strings to represent HTML.
>>
>> deep_profiler/html_format.m:
>>       Convert to using cords. Restructure the code in a couple of places
>>       to always put start and end tags around HTML fragments together.
>>
>>       Fix a missing "=" in a tag.
>>
>> deep_profiler/interface.m:
>> deep_profiler/mdprof_cgi.m:
>> deep_profiler/read_profile.m:
>>       Provide better diagnostics.
>>
>> deep_profiler/create_report.m:
>> deep_profiler/display.m:
>> deep_profiler/display_report.m:
>> deep_profiler/mdprof_feedback.m:
>> deep_profiler/measurement_units.m:
>> deep_profiler/query.m:
>> deep_profiler/report.m:
>> mdbcomp/feedback.m:
>>       Misc cleanups. They can be considered my post-commit review of Paul's
>>       diff.
>>
>>       In mdprof_feedback.m, delete a strange test that prevented the program
>>       from being used from the command line.
>>
>> deep_profiler/dump.m:
>> deep_profiler/mdprof_dump.m:
>> deep_profiler/timeout.m:
>> deep_profiler/util.m:
>>       Misc cleanups of old code.
>>
>
> Thanks for this Zoltan,  I have some minimal comments inline.
>
>>
>> Index: deep_profiler/html_format.m
>> ===================================================================
>> RCS file: /home/mercury/mercury1/repository/mercury/deep_profiler/html_format.m,v
>> retrieving revision 1.22
>> diff -u -b -r1.22 html_format.m
>> --- deep_profiler/html_format.m       29 Jul 2008 01:42:59 -0000      1.22
>> +++ deep_profiler/html_format.m       3 Aug 2008 14:41:36 -0000
>> @@ -11,15 +11,12 @@
>>  %
>>  % This module contains code that sets the format of the HTML tables
>>  % we generate for individual queries.
>> -%
>> -% This module makes many calls to string.append.  In the C backends
>> -% string.append is linear time over the length of both input strings when
>> -% called in in, in, out mode.  If we build a long string from many short
>> -% strings the cost will be quadratic.  It may be better to build a data
>> -% structure with cords to describe how strings should be appended and then
>> -% use calls to string.append_list at a final stage to construct a single
>> -% string from the cord of strings.  There are alternative approaches that
>> -% should reduce the final cost to linear.
>> +
>> +% This module appends many strings. Since string.append takes time that is
>> +% linear over the length of both input strings, building a long string
>> +% from many short strings would take quadratic time. This is why we represent
>> +% HTML as a cord of strings instead. This cord is then converted to a list of
>> +% strings and then a single list just before being given to the browser.
>>  %
>>  %-----------------------------------------------------------------------------%
>

Another way to do this might be to create an instance of the
term_to_xml.xmlable/1 typeclass.  Then call write_xml_doc when you're
ready to print the html.  This will pretty print it automatically and
take care of closing tags correctly.  You also wouldn't have the
problem of appending many strings, since write_xml_doc writes directly
to a stream without creating an intermediate string. You'd be
generating xhtml and not html, but most browsers support xhtml these
days.

Cheers,
Ian.
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list