* displaying time_t values
@ 2005-10-22 23:27 fabio
2005-10-23 10:07 ` Michael Iatrou
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: fabio @ 2005-10-22 23:27 UTC (permalink / raw)
To: linux-c-programming
hello,
I would like to know how to display the full seconds and miliseconds
transacurrent since 2 points in a program.
main()
{
time_t t1_t2;
(void)time(&t1);
cpu_intensive_function();
(void)time(&t2);
printf("the full time spent in the process is:");
// how should i display it ? ej: 51,56745 seconds ot 1024,04546 seconds
}
Thanks,
fabolo
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: displaying time_t values
2005-10-22 23:27 displaying time_t values fabio
@ 2005-10-23 10:07 ` Michael Iatrou
2005-10-24 7:06 ` kaushal
2005-10-24 11:11 ` Glynn Clements
2 siblings, 0 replies; 4+ messages in thread
From: Michael Iatrou @ 2005-10-23 10:07 UTC (permalink / raw)
To: linux-c-programming
When the date was Sunday 23 October 2005 02:27, fabio wrote:
> I would like to know how to display the full seconds and miliseconds
> transacurrent since 2 points in a program.
difftime(t2, t1)
But time won't give you msec resolution.
--
Michael Iatrou
Electrical and Computer Engineering Dept.
University of Patras, Greece
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: displaying time_t values
2005-10-22 23:27 displaying time_t values fabio
2005-10-23 10:07 ` Michael Iatrou
@ 2005-10-24 7:06 ` kaushal
2005-10-24 11:11 ` Glynn Clements
2 siblings, 0 replies; 4+ messages in thread
From: kaushal @ 2005-10-24 7:06 UTC (permalink / raw)
To: fabio; +Cc: linux-c-programming
In case u find the function is over in shorer time,simply run the same
function in a loop for n times and later divide the total time by n.Hope
that was useful.
On Sat, 2005-10-22 at 17:27 -0600, fabio wrote:
> hello,
>
> I would like to know how to display the full seconds and miliseconds
> transacurrent since 2 points in a program.
>
> main()
> {
> time_t t1_t2;
> (void)time(&t1);
> cpu_intensive_function();
> (void)time(&t2);
> printf("the full time spent in the process is:");
> // how should i display it ? ej: 51,56745 seconds ot 1024,04546 seconds
>
> }
>
> Thanks,
>
> fabolo
> -
> To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: displaying time_t values
2005-10-22 23:27 displaying time_t values fabio
2005-10-23 10:07 ` Michael Iatrou
2005-10-24 7:06 ` kaushal
@ 2005-10-24 11:11 ` Glynn Clements
2 siblings, 0 replies; 4+ messages in thread
From: Glynn Clements @ 2005-10-24 11:11 UTC (permalink / raw)
To: fabio; +Cc: linux-c-programming
fabio wrote:
> I would like to know how to display the full seconds and miliseconds
> transacurrent since 2 points in a program.
>
> main()
> {
> time_t t1_t2;
> (void)time(&t1);
> cpu_intensive_function();
> (void)time(&t2);
> printf("the full time spent in the process is:");
> // how should i display it ? ej: 51,56745 seconds ot 1024,04546 seconds
>
> }
time() only provides second resolution. You need to use gettimeofday()
to get better resolution.
--
Glynn Clements <glynn@gclements.plus.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-10-24 11:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-22 23:27 displaying time_t values fabio
2005-10-23 10:07 ` Michael Iatrou
2005-10-24 7:06 ` kaushal
2005-10-24 11:11 ` Glynn Clements
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).