Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Decrement operator
Message
From
02/09/2008 09:00:43
 
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 9.0
OS:
Vista
Network:
Windows 2008 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01344042
Message ID:
01344076
Views:
12
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform