View Single Post
Old 09-06-07, 11:22 AM   #1
six_storm
Registered User
 
six_storm's Avatar
 
Join Date: Jun 2004
Location: Nashvegas
Posts: 11,575
Send a message via Skype™ to six_storm
Default C++ Gurus, School Me :D

Hello all fellow programmers. I'm having a hard time understanding the "time.h" file and it's uses. Currently, I've got a project that is supposed to show the time difference between reading/writing from RAM and reading/writing from disk. My program already performs all 4 functions, I just have to use the "time.h" file to show how long it takes and display it in an external file. So how to you start and stop this "measure of time"? I understand how to convert the number of ticks over to seconds (duh) but I just don't understand how to start and stop timing each function. Can anyone please explain this to me in ENGLISH please? Thanks!

BTW, here were the notes I got on "time.h":

Code:
 	
time.h
	
	
									
• 	To determine the amount of time a section of code takes to run, use the
	following code
	
• 	#include<time.h>
	
	float timer;
	
	timer = clock();              //clock() returns the time in terms of ticks
	
	timer = clock() - timer;  //Gives the elapsed time in ticks
	
	timer /= CLOCKS_PER_SEC;
	
	                                     //Converts ticks to seconds
	
	timer /= 60;                   //Converts seconds to minutes
six_storm is offline   Reply With Quote