[Matlab][Cpp] Time Telling
[Matlab] Generate file name with time
Codes:
fname = sprintf('myfilename_%02d%02d%02d%02d.txt', currTime(2:5) );
[Matlab]Timer
Measure how many seconds were elapsed.Source:
Matlab HelpCodes:
%%%%%%%%%%%%%%%%
% Run your scripts
%%%%%%%%%%%%%%%%
t2 = clock;
Elapsed = etime(t2,t1);
[CPP] Timer Code
Measure how many seconds were elapsed.Source:
http://www.cplusplus.com/ref/ctime/time.htmlCodes:
time_t stime, etime;
stime = time(NULL);
...<Codes to be timed.>...
etime = time(NULL);
printf("Time elapsed: %ld seconds\n", etime-stime);
[CPP] Wait function
Make the program wait for several seconds.Source:
http://www.cplusplus.com/ref/ctime/clock.htmlCodes:
int seconds = 10;
clock_t endwait;
endwait = clock () + seconds * CLOCKS_PER_SEC ;
while (clock() < endwait) {}
[CPP] Print time/date info
Print the current date and timeSource:
http://www.cplusplus.com/reference/clibrary/ctime/ctime.htmlCodes:
#include <stdio.h>
#include <time.h>
int main ()
{
time_t rawtime; }
time ( &rawtime );
printf ( "The current local time is: %s", ctime (&rawtime) );
return 0;