|  | Home | Libraries | People | FAQ | More | 
        Using a simple backend
        class that wraps any built in arithmetic type we can measure the
        overhead involved in wrapping a type inside the number
        frontend, and the effect that turning on expression templates has. The following
        table compares the performance between double
        and a double wrapped inside
        class number:
      
| Type | Bessel Function Evaluation | Non-Central T Evaluation | 
|---|---|---|
| 
                   | 1.0 (0.016s) | 1.0 (0.46s) | 
| 
                   | 1.2 (0.019s) | 1.0(0.46s) | 
| 
                   | 1.2 (0.019s) | 1.7 (0.79s) | 
As you can see whether or not there is an overhead, and how large it is depends on the actual situation, but the overhead is in any cases small. Expression templates generally add a greater overhead the more complex the expression becomes due to the logic of figuring out how to best unpack and evaluate the expression, but of course this is also the situation where you save more temporaries. For a "trivial" backend like this, saving temporaries has no benefit, but for larger types it becomes a bigger win.
        The following table compares arithmetic using either long
        long or number<arithmetic_backend<long long> > for the voronoi-diagram
        builder test:
      
| Type | Relative time | 
|---|---|
| 
                   | 1.0(0.0823s) | 
| 
                   | 1.05 (0.0875s) | 
This test involves mainly creating a lot of temporaries and performing a small amount of arithmetic on them, with very little difference in performance between the native and "wrapped" types.
The test code was compiled with Microsoft Visual Studio 2010 with all optimisations turned on (/Ox), and used MPIR-2.3.0 and libtommath-0.42.0. The tests were run on 32-bit Windows Vista machine.