Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Decrement operator
Message
De
02/09/2008 09:00:43
 
 
À
02/09/2008 08:21:04
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:
01344076
Vues:
13
Viv,

It's debatable. But do confess you're cheating a bit

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 ]
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;
			}
		}
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform