Thursday, January 04, 2007

C# Problem..

I know the title looks strange.. but this issue is provoking me to a very high extent...
I'll tell u why I wrote so...well, When we were testing our Algo project b4 delivering it, we noticed a strange behavior in the performance of our code..
Let me explain wt we were doing first... well, we wanted to calculate the approximate time taken to run the algorithm.. so we made an object from Stopwatch class.. our code looked sth like those lines:

Stopwatch s = new StopWatch();
s.Start();
OurFunction();
s.Stop();

Then later on we display the elapsed time.... Where's the problem then??.. well I will tell u.. the first time we try calling this function, the elapsed time is 4.xxx ms.. while when we try the same input once again (while the exe is still running).. the elapsed time is 0.xxxx.. a gr8 difference !!!!
well.. we noticed sth in our function like creating an object from a class we created.. ex:
Class c = new Class(Var1,Var2); //inside function's body

we thought that this was the reason (sth related with memory allocation , variables initialization.. etc..) we tried initializing everything globally, but still the same thing happened.. we thought about many things (We with the help of Dr Karim), but all in vain..

So, I still don't know why that happens.. mm.. Maybe C# is googling for the place of the function in the memory when we call it for the first time ,so it takes more time !!???

Anyway, please, If anyone has any idea about why this may happen.. Comments are very welcomed..

Tuesday, January 02, 2007

You are a Programmer IF (Cont)...

This is a completion to a previous post You are a Programmer IF

16- You have a volatile Memory like RAM..
17- You write C++,C# or Java better than u write your own language..
18- You don't think wearing sports shoes with a suit is strange..
19- You remember all your passwords, but fail to remember you own birth date..
20- The world 'Engine' reminds you of games more than of cars..
21- Anytime you see a penguin, you think of Linux..
22- You have a LAN in your room..
23- You're the highest-paid yet the worst-dressed person in the office..
24- You follow the instructions only if everything else fails..
25- You use F1 instead of SOS..

(Most if them are Copied.. Copy right reserved)