The first program below illustrates the overhead of array copying and
zeroing:
int fn1()
{
array arg = ({ "a", "b", "c" });
return sizeof(arg);
}
int fn2()
{
array arg = allocate(4711);
return sizeof(arg);
}
void main()
{
int dummy;
int t0 = gethrvtime();
for (int i = 0; i < 100000; i++)
dummy += fn1();
int t1 = gethrvtime();
for (int i = 0; i < 100000; i++)
dummy += fn2();
int t2 = gethrvtime();
werror("fn1: %d ms\n", (t1 - t0) / 1000);
werror("fn2: %d ms\n", (t2 - t1) / 1000);
}
Sample test run (I repeated many times and it was +/- 2 msec):
BEFORE AFTER
--------------------- ---------------------
fn1: 159 ms fn1: 36 ms -77%
fn2: 1194 ms fn2: 777 ms -34%
Next, a large XSL transform which exercises a lot of complex data
structures (again repeatable across several runs):
BEFORE AFTER
--------------------- ---------------------
Parse XML: 82 ms Parse XML: 80 ms
Parse XSL: 1 ms Parse XSL: 1 ms
Transform: 289 ms Transform: 246 ms -15%
Total: 373 ms Total: 328 ms
Another heavy XSL transform (less data, more complex rules):
BEFORE AFTER
--------------------- ---------------------
Parse XML: 17 ms Parse XML: 17 ms
Parse XSL: 4 ms Parse XSL: 4 ms
Transform: 194 ms Transform: 176 ms -9%
Total: 217 ms Total: 198 ms
All compiled with gcc 4.2.1 and run on a 2 GHz quad-code x86_64 Xeon
with 1.33 GHz system bus and 667 MHz DDR2 RAM.