Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Decrement operator
Message
De
02/09/2008 09:35:30
 
 
À
02/09/2008 09:00:43
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 9.0
OS:
Vista
Network:
Windows 2008 Server
Database:
MS SQL Server
Divers
Thread ID:
01344042
Message ID:
01344106
Vues:
13
>Viv,
>
>It's debatable. But do confess you're cheating a bit

<g>

>
>And it doesn't know you're cheating. It stores the decremented value and does not refetch it
>
>I suspect it's by design and for performance reasons [ a dup will be faster than a load ]

Guess so. I looked at your ildasm code and your test below confirms the performance benefit . But I'm not sure whether it's me or MS that's 'cheating' . It could certainly be argued that the decrement operation on ScaleFactor has not been completed when the value is assigned to i........

Regards,
Viv

>
>
>function_zero :   1.4 sec
>function_one:     4.66 sec
>function_two:      6.30 sec
>
>If we subtract the time for the loop
>function_one: 3.26 sec
>function_two: 4.90  sec
>
>3.26/4.9 = .66
>
>And since the ScaleFactor has a getter, it's a call rather than a load
>
>static void Main(string[] args)
>		{
>			Time.Execute(function_zero, false);
>			Time.Execute(function_one, false);
>			Time.Execute(function_two, true);
>			
>		}
>		static void function_zero()
>		{
>			int i, j;
>			for (i = int.MaxValue / 4; --i != 0; )
>			{
>				//j = --ScaleFactor;
>			}
>		}
>		static void function_one()
>		{
>			int i, j;
>			for (i = int.MaxValue/4; --i != 0; )
>			{
>				j = --ScaleFactor;
>			}
>		}
>		static void function_two()
>		{
>			int i, j;
>			for (i = int.MaxValue / 4; --i != 0; )
>			{
>				--ScaleFactor;
>				j = ScaleFactor;
>			}
>		}
>
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform