Hello
Ring 1.27 introduces a major performance improvement to the WebLib library through a new stack-based rendering engine for nested HTML elements. In previous versions, every HTML element created inside a brace block — such as Table, TR, TD, H1, and so on — allocated a separate Ring object in memory. A page with a table of 100 rows and 5 columns would silently create over 500 objects, each carrying hundreds of attributes, output string, and child object list. The overhead of allocating, initializing, and garbage-collecting all these objects was the dominant cost of page generation.
Example:
load "weblib.ring"
import system.web
func main
t1 = clock()
cOutput = createReport()
t2 = clock()
? "Time: " + (t2-t1) + " ms"
write("report.html", cOutput)
system("report.html")
func createReport
nCustCount = 100
oPage = new HtmlPage {
h1 { text("Customers Report") }
Table
{
style = styleWidth("100%")+styleGradient(4)
TR
{
TD { WIDTH = "10%" text("Customers Count : ") }
TD { text(nCustCount) }
}
}
Table
{
style = styleWidth("100%")+styleGradient(26)
TR
{
style = styleWidth("100%")+styleGradient(24)
TD { text("Name ") }
TD { text("Age") }
TD { text("Country") }
TD { text("Job") }
TD { text("Company") }
}
for t=1 to nCustCount
TR
{
TD { text("Test "+t) }
TD { text("30") }
TD { text("Egypt") }
TD { text("Sales") }
TD { text("Future") }
}
next
}
}
return oPage.output()
Output (Using Ring 1.27):
Output (Using Ring 1.26):
Ring 1.27 completes in 9 ms versus 703 ms in Ring 1.26 — a ~78x faster.
Pages with deeper nesting or more rows benefit proportionally. Existing user code requires no changes; the brace-block syntax, attribute assignment, style functions, and all element names work exactly as before.
Note: If we need better performance, we can generate HTML documents using WebLib functions or HTML Templates.
Greetings,
Mahmoud