Monday, November 08, 2010 at 12:05 AM.
system.verbs.builtins.radio.html.viewLog
on viewLog () {
<<Changes:
<<1/21/02; 9:24:50 PM by DW
<<I was able to triple the performance of the page with a simple optimization, cache each of the rows in the table in the log sub-table for the event. Took about ten minutes. Admittedly this is a very simple page, that's why I chose it as a guinea pig. Also save the log database after rendering.
<<1/6/02; 3:55:34 AM by JES
<<Added table css classes.
<<12/11/01; 11:12:28 AM by JES
<<Localized. Decode entities in log item text.
<<12/3/01; 12:37:45 AM by JES
<<Don't add help text. It's in the help-system, linked to from the question mark at the top of the page.
<<11/28/01; 6:50:28 PM by JES
<<Uncommented adding of the help text.
<<1/11/01; 5:33:58 PM by DW
<<We're now doing hourly rollover on the log to improve performance. This script now must traverse tables that are two levels deep.
<<2/15/01; 4:30:23 PM by PBS
<<Prevent macros.
<<2/20/01; 5:08:35 PM by PBS
<<Don't call myUserLandSuite.unTaint here, as items are untainted as needed when added to the log.
<<2/23/01; 10:06:26 PM by PBS
<<Limit to 100 events. If displaying less than a full day of events, put a message at the top of the page saying only 100 events are displayed.
<<2/24/01; 7:21:23 PM by PBS
<<Help link.
if defined (system.temp.radio.htmlCache.viewEventsLog) {
return (system.temp.radio.htmlCache.viewEventsLog)};
local (pta = html.getpagetableaddress ());
pta^.title = radio.string.getlocalizedstring ("eventsLog.title");
local (adrlog = log.getGuestSubTable (radio.data.strings.radioLogName));
local (htmltext = "\r", indentlevel = 0);
on add (s) {
htmltext = htmltext + string.filledstring ("\t", indentlevel) + s + "\r\n"};
add ("<p>" + radio.string.getlocalizedstring ("eventsLog.intro") + " "+ radio.userInterface.helpLink ("The Events Log page") + "</p>");
add ("<table class=\"dwsFrameTable\" cellspacing=\"0\" cellpadding=\"0\"><tr bgcolor=\"" + radio.data.htmlColors.framecolor + "\"><td>"); indentlevel++;
add ("<table border=\"0\" cellspacing=\"1\" cellpadding=\"5\">"); indentlevel++;
bundle { //add header
add ("<tr bgcolor=\"" + radio.data.htmlColors.cellbgcolor + "\"><td class=\"dwsTableCell\"><b>" + radio.string.getlocalizedstring ("eventsLog.eventHeader") + "</b></td><td class=\"dwsTableCell\"><b>" + radio.string.getlocalizedstring ("eventsLog.whatHappenedHeader") + "</b></td><td class=\"dwsTableCell\" align=\"right\"><b>" + radio.string.getlocalizedstring ("eventsLog.timeHeader") + "</b></td><td class=\"dwsTableCell\" align=\"right\"><b>" + radio.string.getlocalizedstring ("eventsLog.secsHeader") + "</b></td></tr>")};
local (adrhour, adritem, i, j, ct = 0);
for i = sizeof (adrlog^) downto 1 {
adrhour = @adrlog^ [i];
for j = sizeof (adrhour^) downto 1 {
adritem = @adrhour^ [j];
if defined (adritem^.cache) {
add (adritem^.cache)}
else {
local (s);
s = s + "<tr bgcolor=\"" + radio.data.htmlColors.cellbgcolor + "\">";
s = s + "<td class=\"dwsTableCell\" valign=\"top\" nowrap>" + adritem^.eventType + "</td>";
s = s + "<td class=\"dwsTableCell\" valign=\"top\">" + radio.string.decodeEntities (adritem^.htmlText) + "</td>";
s = s + "<td class=\"dwsTableCell\" valign=\"top\" align=\"right\" nowrap>" + date.timestring (xml.convertToDisplayName (nameof (adritem^))) + "</td>";
s = s + "<td class=\"dwsTableCell\" valign=\"top\" align=\"right\" nowrap>" + adritem^.secs + "</td>";
s = s + "</tr>";
adritem^.cache = s;
add (s)};
ct++;
if ct >= 100 {
break}};
if ct >= 100 {
break}};
add ("</table>"); indentlevel--;
add ("</table>"); indentlevel--;
<<add ("<a name=\"helpText\"></a>" + radio.string.getlocalizedstring ("eventsLog.helpText"))
filemenu.savemyroot (adrlog);
system.temp.radio.htmlCache.viewEventsLog = htmlText;
return (htmlText)}
<<bundle //test code
<<local (pt)
<<new (tabletype, @pt)
<<new (tabletype, @pt.radioresponder)
<<pt.radioresponder.flsamemachine = true
<<html.setpagetableaddress (@pt)
<<
<<Before cache: 190 ticks; after: 44.
<<local (tc = clock.ticks ())
<<viewLog ()
<<dialog.alert (clock.ticks () - tc)
This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.