Books
in black and white
Main menu
Share a book About us Home
Books
Biology Business Chemistry Computers Culture Economics Fiction Games Guide History Management Mathematical Medicine Mental Fitnes Physics Psychology Scince Sport Technics
Ads

Excel add in development in C++ Aplications in finance - Dalton S.

Dalton S. Excel add in development in C++ Aplications in finance - Wiley publishing , 2005. - 425 p.
ISBN 0-470-02469-0
Download (direct link): exceladdindevelopmentincand2005.pdf
Previous << 1 .. 113 114 115 116 117 118 < 119 > 120 121 122 123 124 125 .. 168 >> Next

It’s important to remember that this kind of test is not 100% scientific: many factors can interfere with the results, such as the operating system or Excel deciding to do some housework behind the scenes. The tests results varied slightly (up to ±5%) each time the tests were run, so they should only be used as a guide to help make the decision about which environment makes most sense.
The tests gave the following results:4
4 The tests were carried out on a DELL Inspiron 4100 laptop computer running Windows 2000 Professional version 5.0 (Service Pack 1, build 2195), with a 730 Megahertz Intel Pentium 4 processor and 128 Megabytes of RAM of which about 20 were free at the time the test was run. No other applications were using significant CPU during the tests on the PC which was not connected to a network. The DLL tested was built from the Release configuration. The version of Excel was 2000.
290
Excel Add-in Development in C/C++
Table 9.3 VB function test results
Test action Inner loop Outer loop Other arguments Seconds to complete
TestO No action 1,000 30,000 0.72
Testl Integer const assignment 1,000 30,000 1.99
Test2 Double const assignment 1,000 30,000 2.40
Test3 Integer variable assignment 1,000 30,000 2.24
Test4 Double variable assignment 1,000 30,000 2.23
Test5 Double const multiplication 1,000 30,000 2.39
Test6 Exp() evaluation and assignment 300 30,000 3.68
Test7 Degree-4 double polynomial evaluation (const coefficients) 100 30,000 0.64
Test8 Sum 10-element double vector 100 30,000 1.46
Test9 Double array allocation test 1 30,000 1,000 1.86
Testl 0 Simple function call 1,000 30,000 10.70
Testl 1 Sum of ASCII values of string 100 30,000 abcdefghi 19.16
Table 9.4 C function test results
Test action Inner loop Outer loop Other arguments Seconds to complete
TestO No action 1,000 30,000 0.32
Testl Integer const assignment 1,000 30,000 0.29
Test2 Double const assignment 1,000 30,000 0.29
Test3 Integer variable assignment 1,000 30,000 0.25
Test4 Double variable assignment 1,000 30,000 0.33
Test5 Double const multiplication 1,000 30,000 0.42
Miscellaneous Topics 291
Table 9.4 (continued)
Test action Inner loop Outer loop Other arguments Seconds to complete
Test6 Exp() evaluation and assignment 300 30,000 3.02
Test7 Degree-4 double polynomial evaluation (const coefficients) 100 30,000 0.06
Test8 Sum 10-element double vector 100 30,000 0.07
Test9 Double array allocation test 1 30,000 1,000 0.85
TestIO Simple function call 1,000 30,000 2.37
Test11 Sum of ASCII values of string 1,000 30,000 abcdefghi 0.62
Table 9.5 Test results comparison
Test Action Performance ratio C/C++ : VB
TestO No action 1 : 2.2
Testl Integer const assignment 1 : 6.7
Test2 Double const assignment 1 : 8.8
Test3 Integer variable assignment 1 : 7.9
Test4 Double variable assignment 1 : 6.8
Test5 Double const multiplication 1 :5.6
Test6 Exp() evaluation and assignment 1 : 1.1
Test7 Deg-4 double polynomial evaluation (const coefficients) 1 : 9.5
Test8 Sum of double vector elements (10) 1 : 21.8
Test9 Double array allocation test 1 : 2.1
TestIO Simple function call 1 :4.5
Testl 1 Sum of ASCII values of string 1 : 309
Notes:
Test 0
This was a do nothing test to measure the difference in wrapper function execution times. Interestingly, as you may have noticed, the do nothing test in C took 10% longer to execute than the test which assigned a constant value to either an integer or a double!5
5 Despite having looked at the assembler output, the author has no explanation for this. There may be a more rational explanation, but perhaps the compiler and Windows have a collective sense of humour.
292
Excel Add-in Development in C/C++
Tests 1 to 5
These tests show that C/C++ code is faster by a factor of 6 to 8 for regular variable assignments and simple algebraic operations.
Test 6
In this test, most of the time is being spent calling the VB Exp() or the C exp() library functions, which are roughly as efficient as each other. This reflects the fact that, unsurprisingly, VB can call a compiled Microsoft library function just about as quickly as C can. If you take out the times of Test 0 from scaled-up times for Test 6, the ratio becomes even closer at 1 : 1.002. (It is also interesting to note that the statement v = exp(1.5); executes roughly 45 times slower than v = 1.5; and about 40 times slower than v1 = v2.)
Test 7
In both cases the test code was written so as to use the minimum number of multiplications, as well additions, to evaluate the polynomial. The relatively large ratio indicates partly that VB takes far more time to process all of the symbols in the line, despite being partially pre-compiled. This tends to exaggerate the ratios seen in tests 1 through 5.
Test 8
The same reasoning applies in part to this test as Test 7, i.e., the large number of symbols exaggerate the performance differential. However, it’s clear that C/C++ is far more efficient at evaluating array index references than VB.
Previous << 1 .. 113 114 115 116 117 118 < 119 > 120 121 122 123 124 125 .. 168 >> Next