tag:blogger.com,1999:blog-17926206.post6794563075448963159..comments2023-06-05T00:22:57.371-07:00Comments on I c#de, therefore I exist ;: C# Problem..Roaahttp://www.blogger.com/profile/10864687378207475258noreply@blogger.comBlogger17125tag:blogger.com,1999:blog-17926206.post-72615956523104516312010-11-23T22:18:08.019-08:002010-11-23T22:18:08.019-08:00Interesting article, added his blog to FavoritesInteresting article, added his blog to Favoritescialishttp://www.agir-galiza.org/noreply@blogger.comtag:blogger.com,1999:blog-17926206.post-4215878999661809882007-05-25T00:07:00.000-07:002007-05-25T00:07:00.000-07:00Thanks for the comment...I will try that soon isAl...Thanks for the comment...<BR/>I will try that soon isAllah & tell u the feedback..Roaa Mohammedhttps://www.blogger.com/profile/02159334456559077710noreply@blogger.comtag:blogger.com,1999:blog-17926206.post-54331743374794481322007-05-24T21:21:00.000-07:002007-05-24T21:21:00.000-07:00asalam 3alikomdid you hear about "native .net asse...asalam 3alikom<BR/>did you hear about "native .net assembly images" ?<BR/><BR/>Actually the issue that haytham said about converting functions or classes to native code at run-time is true.<BR/><BR/>so, If the native conversion is the problem of the code u mentioned, I guess here is a solution (as haytham said, I am lazy, just guess!), anyway:<BR/><BR/>Microsoft made a utility called "ngen.exe"(Native Image Generator) shipped with the .net framework, it makes a native image of a given .net assembly (exe or dll), and installs it to the (native images cache), which you will see in the "Assembly cache" in "Microsoft .NET Framework 2.0 Configuration", so that The runtime can use native images from the cache instead of using the just-in-time (JIT) compiler to compile the original assembly<BR/><BR/>does this solve your problem ?Mahmoud Hossamhttps://www.blogger.com/profile/07966152391246945578noreply@blogger.comtag:blogger.com,1999:blog-17926206.post-60604398605553086812007-03-31T11:07:00.000-07:002007-03-31T11:07:00.000-07:00Thanks Meshref for this piece of info...Thanks Meshref for this piece of info...Roaa Mohammedhttps://www.blogger.com/profile/02159334456559077710noreply@blogger.comtag:blogger.com,1999:blog-17926206.post-71602495740607776092007-03-26T22:57:00.000-07:002007-03-26T22:57:00.000-07:00About why C++ is also late in doing this, it's som...About why C++ is also late in doing this, it's something similar, when you load you native image in the memory, it's not loaded completely in the memory, but it's loaded according to the code segments, in other words if you have a function which is not used so much, it'll be thrown to the dead zone of the code segment (usually on the v.memory) and when you use it, it'll be in the main segment, and may be in the cashe.<BR/><BR/>Refer to a topic called "Profile Guided Optimization" for more information about thisMohamed Moshrifhttps://www.blogger.com/profile/04748476186265746697noreply@blogger.comtag:blogger.com,1999:blog-17926206.post-35805444842601658822007-01-06T23:04:00.000-08:002007-01-06T23:04:00.000-08:00:):)Roaa Mohammedhttps://www.blogger.com/profile/02159334456559077710noreply@blogger.comtag:blogger.com,1999:blog-17926206.post-43503440652184869362007-01-06T15:45:00.000-08:002007-01-06T15:45:00.000-08:00strange!strange!Mohammed ElMorsyhttps://www.blogger.com/profile/04101409831153656863noreply@blogger.comtag:blogger.com,1999:blog-17926206.post-9543993888291491482007-01-05T09:10:00.000-08:002007-01-05T09:10:00.000-08:00Uploaded the code here
http://www.box.net/public/4...Uploaded the code here<br />http://www.box.net/public/4hyam17hqhRoaa Mohammedhttps://www.blogger.com/profile/02159334456559077710noreply@blogger.comtag:blogger.com,1999:blog-17926206.post-70410992260420430622007-01-05T03:20:00.000-08:002007-01-05T03:20:00.000-08:00commenting bel-triple :¦
jazana wa eyakom,
...commenting bel-triple :¦<br /><br />jazana wa eyakom,<br />first, i knew u were joking..sorry for the tough entry :$<br />second, yes i wanna have a look at ur code, wish u best luck :)<br /><br />al salamo 3alikom wa ra7mato AllahMohammed ElMorsyhttps://www.blogger.com/profile/04101409831153656863noreply@blogger.comtag:blogger.com,1999:blog-17926206.post-63010855380090276342007-01-05T03:02:00.000-08:002007-01-05T03:02:00.000-08:00al salamo 3alikom..
ezzaher enny ba2et ba-comment...al salamo 3alikom..<br /><br />ezzaher enny ba2et ba-comment pairs!<br />el mohem.. i've tried the code on C++ (unmanaged) and resulted the same thing.<br /><br />al salamo 3alikom wa ra7mato AllahMohammed ElMorsyhttps://www.blogger.com/profile/04101409831153656863noreply@blogger.comtag:blogger.com,1999:blog-17926206.post-28767962411534652232007-01-05T02:59:00.000-08:002007-01-05T02:59:00.000-08:00Al Salamo 3alikom..
To Mohammed a.aziz:
First, SU...Al Salamo 3alikom..<br /><br />To Mohammed a.aziz:<br />First, SURE I'm joking about the 'googling' thing..<br /><br />Second, Maybe 4ms is not a big difference, but when all the other outputs are 0.3:0.2.. at least,it doesn't look good when displaying that to the user (for example)<br />yeah, I tried running my code more than 100 times, The time differs each time for sure, but still the 4.xxx ms difference..<br /><br />Third, thx for ur help.. if u still want to have a look at the code,tell me & I will upload it & send u a link..<br /><br />To Asmaaa:<br />Actually we tried all possible things, & it has nth to do with the input.. (also in our code, we can't try the exact same input 2we..so we'r just approximating) <br /><br />To Haytham Alaa:<br />Actually, this is wt I thought about, But I thought it doesn't turn our Class functions & variables to native code except when we use them.. so that's y I tried to make an object from it & use its functions b4 usage (which didn't make a big difference -maybe 1.xx ms difference only-..<br />I didn't think & know that it doesn't execute my main function too..(turn it to native assembly code) <br /><br />Jazak Allaho 7'ayran for this info & for the sample code..<br /><br />Thanks all for ur help..Roaa Mohammedhttps://www.blogger.com/profile/02159334456559077710noreply@blogger.comtag:blogger.com,1999:blog-17926206.post-29780283509736769792007-01-05T01:06:00.000-08:002007-01-05T01:06:00.000-08:00al salamo 3alikom..
jazak Allah 7'ayran ya haytha...al salamo 3alikom..<br /><br />jazak Allah 7'ayran ya haytham for the "Lazy" information ;)<br />could u plz try running ur code more than twice :D .. timespan increases..<br />if u have any links about lazy technique with IL plz send it..as I've found "how to lazy loading in ur code"<br />very good info, al salamo 3alikom wa ra7mato AllahMohammed ElMorsyhttps://www.blogger.com/profile/04101409831153656863noreply@blogger.comtag:blogger.com,1999:blog-17926206.post-64070484765077353842007-01-04T22:16:00.000-08:002007-01-04T22:16:00.000-08:00Alsalam alikom wa ra7mat Allah wa barakatoh
I did...Alsalam alikom wa ra7mat Allah wa barakatoh<br /><br />I did a test keda which I guess proves what I say (howa tab3an law 7ad dawar online hayla2ee el mofeed... bas ne3mel eih b2a a7'oko lazy)<br /><br />this is my Main class :<br />class Program<br /> {<br /> static void Main(string[] args)<br /> {<br /> Class1 c = new Class1();<br /> Stopwatch s = new Stopwatch();<br /> for (int i = 0; i < 2; i++)<br /> {<br /> s.Start();<br /> c.Run();<br /> s.Stop();<br /> Console.WriteLine(s.ElapsedMilliseconds);<br /> s.Reset();<br /> }<br /> }<br /> }<br /><br />More or less, it's like Zezo's..<br />Then I have this as Class1 :<br />class Class1<br /> {<br /> public void Run()<br /> {<br /> for (int i = 0; i < 10000000; i++)<br /> ;<br /> }<br /> }<br /><br />Now when I run it, it prints out<br />17<br />18<br />or <br />18<br />19<br /><br />Things like this, which is not good at all... just wait and c..<br />Now I put another "depth" in the program..<br />The main class is not changed<br />class1 is like this :<br />class Class1<br /> {<br /> public void Run()<br /> {<br /> Class2 c = new Class2();<br /> c.Run();<br /> }<br /> }<br />and class2 is like this<br />class Class2<br /> {<br /> public void Run()<br /> {<br /> for (int i = 0; i < 10000000; i++)<br /> ;<br /> }<br /> }<br /><br />as u c the first program what like this <br />Main -> Class1<br />now it's <br />Main -> Class1 -> Class2<br /><br />now the results is somehow accepted<br />19<br />18<br />or <br />19<br />17<br />good enough..<br />now I added another depth<br />Main -> Class1 -> Class2 -> Class3<br />I'll not put more code.. u what I mean already.<br /><br />Now the results r<br />32<br />20<br />or<br />22<br />17<br /><br />And things like this.. which is more and more accepted..<br /><br />What I was trying to do is to "deceive" the CLR.. I'm trying to let it "don't" load all my classes at once....<br /><br />mmm ta2reeban kan hayb2a ashal law dawwar online... yalla msh adyah..<br /><br />Hope that was useful (and/or) right..<br /><br />Alsalam alikom wa ra7mat Allah wa barakatohHaytham Alaahttps://www.blogger.com/profile/02835085630794860777noreply@blogger.comtag:blogger.com,1999:blog-17926206.post-74486664271275822552007-01-04T22:00:00.000-08:002007-01-04T22:00:00.000-08:00Alsalam Alikom wa ra7mat Allah wa barakatoh,
Actu...Alsalam Alikom wa ra7mat Allah wa barakatoh,<br /><br />Actually, as far as I know ya3nee, .NET has something called "Lazy Binding" or "Lazy Loading".. something like this..<br /><br />el mohem,<br />You know that all ur code is compiled to MSIL code (Microsoft Intermediate Language).. it's a readable code that can't be executed on the Processor Directly, that's why we need the .NET framework to run our .NET Application..<br /><br />When you double-click your exe, the .NET Framework loads the main class and the main function (loads here mean converts them into native Assembly and puts them somewhere in RAM so that the processor can execute them)<br />let's say it "recompiles" your MSIL into native code to be executed..<br /><br />but it's smart enough that it doesn't recompile everything, it compiles the part that will be needed soon... and so on..<br /><br />So I guess it's clear what happens in ur case..<br /><br />you call function X (which is not yet native assembly) so .NET Framework takes some time till it convert it to native assembly.<br />Once done, any later calls will be faster than the first one..<br /><br />So, if you did what Asmaa suggested about running a different input, I guess that it'll be fast too..<br /><br />Haza wallahu a3lam..<br /><br />Alsalam alikom wa ra7mat Allah wa barakatohHaytham Alaahttps://www.blogger.com/profile/02835085630794860777noreply@blogger.comtag:blogger.com,1999:blog-17926206.post-78376239335920426902007-01-04T18:01:00.000-08:002007-01-04T18:01:00.000-08:00al salamo 3alikom wa ra7mato Allah,
asmaa comment...al salamo 3alikom wa ra7mato Allah,<br /><br />asmaa comment reminded me with some code i've seen on some website :D that memoize function calls in .net..ma 3alena..<br />I've just recognized that difference of 4 milliseconds is not a deal (i've 5 milli differene in my program), as i guess, in multi-processing environment (Windows OS), try running ur code more than twice.<br /><br />al salamo 3alikom wa ra7mato AllahMohammed ElMorsyhttps://www.blogger.com/profile/04101409831153656863noreply@blogger.comtag:blogger.com,1999:blog-17926206.post-13456200997194187312007-01-04T15:19:00.000-08:002007-01-04T15:19:00.000-08:00Well, I have a small idea that mieght be useless b...Well, I have a small idea that mieght be useless but I'll say it anyway :D.<br />lamma garrabty el input twice, kano wara b3d?? if so, try to put a different input in the middle.<br />Maybe el C# is so clever that it knew this input was exactly as the previous one so it remembered the answer so quickly ;)Asmaa Magdihttps://www.blogger.com/profile/00912674976343690042noreply@blogger.comtag:blogger.com,1999:blog-17926206.post-57831343838770865332007-01-04T14:51:00.000-08:002007-01-04T14:51:00.000-08:00al salamo 3alikom...
I couldn't imagine a program...al salamo 3alikom...<br /><br />I couldn't imagine a programming lanuage is searching for function, it's something as simple as a table of fnction name pointing to it's address<br />I've tried that code and it result an acceptable output (kan nefsy yb2a formatted :D):<br /><br /> class ProgramClass<br /> {<br /> public void Run()<br /> {<br /> int x = 0;<br /> while (x < 10000000)<br /> {<br /> x++;<br /> }<br /> }<br /> }<br /> static void Main(string[] args)<br /> {<br /> ProgramClass p = new ProgramClass();<br /> Stopwatch s = new Stopwatch();<br /> for (int i = 0; i < 5; i++)<br /> {<br /> s.Start();<br /> p.Run();<br /> s.Stop();<br /> Console.WriteLine(s.Elapsed.TotalMilliseconds);<br /> s.Reset();<br /> }<br /> }<br /><br /><b>output:</b><br />21.0328<br />23.2551<br />25.7764<br />21.2756<br />27.556<br /><br />If u could send ur code, that would be nice<br /><br />al salamo 3alikm wa ra7mato AllahMohammed ElMorsyhttps://www.blogger.com/profile/04101409831153656863noreply@blogger.com