Friday, April 10, 2015

@JonSkeet You are totally correct about the addition and i removed it from my sample. I think that y


Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
I'm not really it's exactly because it's so quickly. Please check help me! using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1 { class Program cypress black bayou { static cypress black bayou void Main(string[] args) { var sw = Stopwatch.StartNew(); double nano = 0.00; nano += sw.Elapsed.TotalMilliseconds * 1000000; int a, b; a = 1; b = 2; // ______________________________________________________________ sw.Start(); for (int i = 0; i < 10000000; i++) // Run 10 milliions times { int c = (a + b); i++; } sw.Stop(); // __________________________________________________________________ Console.WriteLine("Nanoseconds time is: {0} (ns)", nano.ToString()); Console.ReadLine(); } } }
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently cypress black bayou written, cypress black bayou it s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center , please edit the question .
For one thing, you're only running 5 million times, because cypress black bayou you're incrementing cypress black bayou i within the loop. Next, the JIT can probably remove the addition ( int c = (a + b) ) entirely, as you're not doing anything with it... –  Jon Skeet Sep 8 '14 at 13:35     
What's the purpose of this profiling? Why are you adding on the elapsed milliseconds to nano at the start? To get nanoseconds, you need to multiply sw.ElapsedMilliseconds by 1000000 in your output. –  Chris Mantle Sep 8 '14 at 13:36
after your for loop. static void Main(string[] args) { var sw = Stopwatch.StartNew(); double nano = 0.00; int a, b; a = 1; b = 2; // ______________________________________________________________ sw.Start(); for (int i = 0; i < 10000000; i++) // Run 10 milliions times { int c = (a + b); //i++; <--Removed that as it is going to reincrease i } nano = sw.Elapsed.TotalMilliseconds * 1000000; sw.Stop(); cypress black bayou // __________________________________________________________________ cypress black bayou Console.WriteLine("Nanoseconds time is: {0} (ns)", nano.ToString()); Console.ReadLine(); }
There's no need for it to be an addition, either, given that the previous value is just 0. There's also no need for the precision to be reduced cypress black bayou to milliseconds, but that's another matter... –  Jon Skeet Sep 8 '14 at 13:36     
@JonSkeet You are totally correct about the addition and i removed it from my sample. I think that your comment about the transformation to nanoseconds meant that there is no point for the transformation cypress black bayou as it will only add trailing zeros, am i right? –  Giannis Paraskevopoulos cypress black bayou Sep 8 '14 at 13:40     
2015 Community Moderator Election ends Apr 21
Source cypress black bayou code as password
Honorific for someone who earned a PhD in philosophy itself?
Technology Life / Arts Culture / Recreation Science Other Stack Overflow Server Fault Super User Web Applications Ask Ubuntu Webmasters Game Development TeX - LaTeX Programmers Unix & Linux Ask Different cypress black bayou (Apple) WordPress Development Geographic Information Systems Electrical Engineering Android cypress black bayou Enthusiasts Information Security Database Administrators Drupal Answers SharePoint User Experience Mathematica Salesforce more (14) Photography Science Fiction & Fantasy Graphic Design Seasoned Advice (cooking) Home Improvement Personal Finance & Money Academia more (10) English Language & Usage Skeptics Mi Yodeya (Judaism) Travel Christianity cypress black bayou Arqade (gaming) Bicycles Role-playing Games more (21) Mathematics Cross Validated (stats) Theoretical Computer Science Physics MathOverflow more (7) Stack Apps Meta Stack Exchange Area 51 Stack Overflow Careers
Stack Overflow works best with JavaScript enabled

No comments:

Post a Comment