Test Results
To measure performance gain in execution time and space, I present two programs:
- One that uses expression templates.
- The other relies on brute-force operator overloading.
Both calculate the following expression:
v = (v1*v1*v2 + v1*v1*v3 + v1*v2*v2 + v1*v2*v3 +
v1*v3*v3 + v2*v2*v2 + v2*v2*v3)/(v1*v2*v3);
where v1, v2, and v3 are the input vectors. To make resource utilization easy to measure, the programs calculate expressions over Vectors containing 8 million double-precision numbers. To exclude the cost of program startup and initialization, and account for variability from one run to another, I arranged for both programs to repeat the evaluation of the expression multiple times, after the input vectors have been initialized. A timestamp is taken immediately before and immediately after the evaluation. Memory utilization is measured with perfmon.exe, a commonly used Windows tool. The test programs were compiled with Visual C++ 2005. The following numbers shows average values after repeating the test several times on a typical well-equipped PC running Windows XP Professional. The peak memory utilization numbers do not include memory consumed by the three input Vectors and the output Vector.
Expression templates
- Peak memory utilization: 0 bytes, no temporaries created.
- Execution time: 0.3 seconds.
Brute-force operator overloading
- Peak memory utilization: 1.33Gb
- Execution time: 2.1 seconds



