из моего таймера кода VB
Dim SquareInches As Double
Dim MMSquared As Double = 81
Const d As Double = 645.16
Const m As Double = 1 / 645.16
Private Function TestCase1() As Boolean 'One
'Test One Code Here
SquareInches = MMSquared / d
'end test code
Return True
End Function
Private Function TestCase2() As Boolean 'Two
'Test Two Code Here
SquareInches = MMSquared * m
'end test code
Return True
End Function
Результаты
3/17/2009 2:13:27 PM CPU - 1.794GHz
One - Using Division
Two - Using Multiplication
Outer Loops(OL)=7 Inner Loops=262,144
( times in ticks. 1 ms. = 10,000 ticks )
>> Two faster, 0.0488 ticks/loop
Ticks / Loop
0.0342 0.0819 0.0331 0.0488
OL Base One Two One - Two
1 8,936 21,459 8,609 12,850
2 9,008 21,416 8,682 12,734
3 8,965 21,423 8,643 12,780
4 8,964 21,457 8,659 12,798
5 8,966 21,469 8,640 12,829
6 8,987 21,660 8,688 12,972
7 8,963 21,429 8,802 12,627
Average
8,969 21,473 8,674 12,799
Variance
431.4 6,160.3 3,315.9
Standard Deviation
20.8 78.5 57.6
3/17/2009 2:13:27 PM