Prev: Signing a File!
Next: DirectX SDK error in C++ program
From: Joe Gambler on 10 Sep 2009 10:58 Hi, I am currently learning C using VS 2005 at a local college and we have an assignment that requires me to print a start time (for a sort function of 100,000 records), a finish time and the time (in seconds:milliseconds) taken to complete the sort. The output should be: Bubble Sort Started 15:52:34.791 ` Finished 15:53:34.277 59.486 seconds Insertion Sort Started 15:54:00.100 Finished 15:54:10.100 10.000 seconds difftime ............ will not allow for milliseconds time(&start) ..... " " " _strtime_s ........ is a char _ftime64_s ...... __timeb64........ __time64......... The .millitm seems to be the only option that will give me ONLY the milliseconds, but I don't understand how this option will help with the seconds:milliseconds result I'm required to produce. Any help would be appreciated. Cheers
From: Vincent Fatica on 10 Sep 2009 14:30 Hint: milliseconds since 00:00:00 1-1-1970 will be .time * 1000 + .millitm On Thu, 10 Sep 2009 07:58:30 -0700 (PDT), Joe Gambler <gambler.hush(a)gmail.com> wrote: |Hi, |I am currently learning C using VS 2005 at a local college and we have |an assignment that requires me to print a start time (for a sort |function of 100,000 records), a finish time and the time (in |seconds:milliseconds) taken to complete the sort. | |The output should be: | |Bubble Sort Started 15:52:34.791 |` Finished 15:53:34.277 59.486 seconds | |Insertion Sort Started 15:54:00.100 | Finished 15:54:10.100 10.000 seconds | | |difftime ............ will not allow for milliseconds |time(&start) ..... " " " |_strtime_s ........ is a char |_ftime64_s ...... |__timeb64........ |__time64......... | |The .millitm seems to be the only option that will give me ONLY the |milliseconds, but I don't understand how this option will help with |the seconds:milliseconds result I'm required to produce. | |Any help would be appreciated. | |Cheers -- - Vince
From: Ulrich Eckhardt on 11 Sep 2009 03:09 Joe Gambler wrote: > [...]we have an assignment that requires me to print a start time > (for a sort function of 100,000 records), a finish time and the > time (in seconds:milliseconds) taken to complete the sort. [...] > difftime ............ will not allow for milliseconds > time(&start) ..... " " " > _strtime_s ........ is a char > _ftime64_s ...... > __timeb64........ > __time64......... > > The .millitm seems to be the only option that will give me ONLY the > milliseconds, but I don't understand how this option will help with > the seconds:milliseconds result I'm required to produce. There is a precise, monotonic timer source available as timeGetTime(), returning milliseconds. You will need to link the according library though. #include <mmsystem.h> #pragma comment(lib, "winmm.lib") Other than that, you missed a common function in your research: clock(). Uli -- Sator Laser GmbH Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932
From: Joe Gambler on 11 Sep 2009 03:15 On Sep 11, 4:30 am, Vincent Fatica <vi...(a)blackholespam.net> wrote: > Hint: milliseconds since 00:00:00 1-1-1970 will be > > .time * 1000 + .millitm > > - Vince Do you ever get the feeling that your totally stupid? You obviously don't, but I certainly feel that way now!! Thanks for helping provide the answer I needed. Cheers Joe
From: Joe Gambler on 11 Sep 2009 03:37
On Sep 11, 5:09 pm, Ulrich Eckhardt <eckha...(a)satorlaser.com> wrote: > Joe Gambler wrote: > > [...]we have an assignment that requires me to print a start time > > (for a sort function of 100,000 records), a finish time and the > > time (in seconds:milliseconds) taken to complete the sort. > [...] > > difftime ............ will not allow for milliseconds > > time(&start) ..... " " " > > _strtime_s ........ is a char > > _ftime64_s ...... > > __timeb64........ > > __time64......... > > > The .millitm seems to be the only option that will give me ONLY the > > milliseconds, but I don't understand how this option will help with > > the seconds:milliseconds result I'm required to produce. > > There is a precise, monotonic timer source available as timeGetTime(), > returning milliseconds. You will need to link the according library though. > > #include <mmsystem.h> > #pragma comment(lib, "winmm.lib") > > Other than that, you missed a common function in your research: clock(). > > Uli > > -- > Sator Laser GmbH > Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932 Now I feel even more foolish. But, I thank you for providing me with the function. Regards |