Wednesday 15 January 2014

How to get the time elapsed in C in milliseconds? (Windows) -


I searched the web but I just found a way to do it, but it came back like this Seconds instead of milliseconds

My code is:

  #include & lt; Stdio.h & gt; # Include & lt; Assert.h & gt; # Include & lt; Time.h> Int main (zero) {int solucion; Time_t start, stop; Watch_t; Long count; Time (& amp; Beginning); Solucion = divisores_it (92000000, 2); Time (& amp; stop); Printf ("Finished in% f second". \ N ", Fitime (stop, start)); Return 0; }   

There is a cross-platform way to use Fry < P> Windows Specific Link Here:

Example below.

  #include & lt; Stdio.h & gt; # Include & lt; Sys \ timeb.h & gt; Int main () {struct timeb start, end; Int diff; Int i = 0; Ftime (& start); While (i ++> 999) do something that takes some time * / printf ("."); } Ftime (and end); Diff = (int) (1000.0 * (end.time - start.time) + (end militum - start militum)); Printf ("\ nOveration% u took millions of seconds \ n", diff); Return 0; }   

I ran the code and detected it using VS2008 and found that it actually calls the GetSystemTimeAsFileTime function.

Anyway, the Fight will give you the accuracy of the millisecond.

No comments:

Post a Comment