By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,376 Members | 1,668 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,376 IT Pros & Developers. It's quick & easy.

Measuring time differences

P: n/a
Hi!

I'm currently implementing a program which measures voltages through an
external USB-AD-converter. It should output those values as time/voltage
pairs.

My problem is to measure the time to output (time elapsed since program
start would do just fine) - it should be as precise as possible, as
there may be only differences in milliseconds between two measurements.

Currently I'm using (clock()/float(CLK_TCK)) as time value, which is not
accurat enough as I get something like:

Time Voltage
0 0
0 0.062474
0 0.124792
0.01 0.186798
0.01 0.248337
0.01 0.309255
0.01 0.3694
0.02 0.428622
0.02 0.486773
0.02 0.543707
0.02 0.599282
0.02 0.653359
0.03 0.705803
0.03 0.756483
0.03 0.805272
0.03 0.852048
0.03 0.896695
0.04 0.939101
0.04 0.979159
0.04 1.01677

So I need a more precise way of measuring time differences. What
functions are available in C to do so? I'd like to keep my program as
portable as possible, but finally it should run only on a Windows/DOS
machine, so I can also use DOS-only functions if neccessary.

Thank you very much!
Yours,
Dominik Wallner
Dec 16 '05 #1
Share this Question
Share on Google+
74 Replies


P: n/a
you could use gettimeofday() when you start and then call it
periodically after that, comparing the values with the one at the start
of the experiment. gettimeofday() returns the current time in seconds
and microseconds.

Dec 16 '05 #2

P: n/a
"coder1024" <co*******@gmail.com> writes:
you could use gettimeofday() when you start and then call it
periodically after that, comparing the values with the one at the start
of the experiment. gettimeofday() returns the current time in seconds
and microseconds.


Please read <http://cfaj.freeshell.org/google/>.

gettimeofday() is not standard C. In fact, it's defined by the POSIX
standard, and since the OP is using a Windows/DOS environment, it's
likely not to be available.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Dec 16 '05 #3

P: n/a
Dominik Wallner <do*******@yahoo.de> writes:
I'm currently implementing a program which measures voltages through an
external USB-AD-converter. It should output those values as time/voltage
pairs.

My problem is to measure the time to output (time elapsed since program
start would do just fine) - it should be as precise as possible, as
there may be only differences in milliseconds between two measurements.

Currently I'm using (clock()/float(CLK_TCK)) as time value, which is not
accurat enough as I get something like: [snip]

clock() measure CPU time, not real time.
So I need a more precise way of measuring time differences. What
functions are available in C to do so? I'd like to keep my program as
portable as possible, but finally it should run only on a Windows/DOS
machine, so I can also use DOS-only functions if neccessary.


There are no portable functions in standard C to measure time with any
particular precision. The time() function returns a value of time
time_t, which is merely an arithmetic type capable of representing
times; a typical resolution is 1 second, but there are no guarantees.

You should ask in a DOS or Windows newsgroup.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Dec 16 '05 #4

P: n/a
Dominik Wallner wrote:
Hi!

I'm currently implementing a program which measures voltages through an
external USB-AD-converter. It should output those values as time/voltage
pairs.

My problem is to measure the time to output (time elapsed since program
start would do just fine) - it should be as precise as possible, as
there may be only differences in milliseconds between two measurements.

Currently I'm using (clock()/float(CLK_TCK)) as time value, which is not
accurat enough as I get something like:

Time Voltage
0 0
0 0.062474
0 0.124792
0.01 0.186798
0.01 0.248337
0.01 0.309255
0.01 0.3694
0.02 0.428622
0.02 0.486773
0.02 0.543707
0.02 0.599282
0.02 0.653359
0.03 0.705803
0.03 0.756483
0.03 0.805272
0.03 0.852048
0.03 0.896695
0.04 0.939101
0.04 0.979159
0.04 1.01677

So I need a more precise way of measuring time differences. What
functions are available in C to do so? I'd like to keep my program as
portable as possible, but finally it should run only on a Windows/DOS
machine, so I can also use DOS-only functions if neccessary.


Wrap your time measurement into functions or macros, e.g.
START_TIME
CURR_TIME
STOP_TIME
and put your non-portable solution behind that. This way,
you only have to change the function or macro definition.

A good starting point to ask about system specific solutions
may be
comp.os.ms-windows.programmer

Note: Above, you are using float; consider using double if
you want to be sure to have more than six significant digits.

Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Dec 16 '05 #5

P: n/a
coder1024 wrote:
you could use gettimeofday() when you start and then call it
periodically after that, comparing the values with the one at the start
of the experiment. gettimeofday() returns the current time in seconds
and microseconds.


There are two horrible errors in your post:
1) You provide no context for your "answer." I attribute this to your
not knowing how to use groups.google.com correctly.
1a) Had you followed normal civil usenet practice and followed the
newsgroup before posting, you would know how to do this
correctly.
2) You provide an "answer" that uses a function that is not part of the
standard C programming language. gettimeofday() has no definition in C.
What arguments it takes, what values it returns, and what its side
effects might be are completely undefined in C.
2a) Had you followed normal civil usenet practice and followed the
newsgroup before posting, you would know not to provide such
non-answers.
Dec 16 '05 #6

P: n/a
coder1024 wrote:
you could use gettimeofday() when you start and then call it
periodically after that, comparing the values with the one at the start
of the experiment. gettimeofday() returns the current time in seconds
and microseconds.


Please provide context, people may not have seen the message you are
replying to since Google is only one of thousands of servers and
propogation between servers is not perfect. See
http://cfaj.freeshell.org/google/ for more details.

As to gettimeofday, that is a Unix function and is NOT part of the C
language and standard library. So, apart from being off topic here (we
only deal with standard C) it won't solve the OPs problem if s/he is
using DOS or Windows (which is the OPs situation).
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Dec 16 '05 #7

P: n/a
Dominik Wallner wrote:

<snip>
My problem is to measure the time to output (time elapsed since program
start would do just fine) - it should be as precise as possible, as
there may be only differences in milliseconds between two measurements.

Currently I'm using (clock()/float(CLK_TCK)) as time value,
clock give you CPA time which, on a multi-tasking OS (and even in DOS if
TSRs are eating processing time) is *not* the same as real time, and I
strongly suspect you want real time rather than CPU time.
which is not
accurat enough as I get something like:

Time Voltage
0 0
0 0.062474
0 0.124792
<snip>
So I need a more precise way of measuring time differences. What
functions are available in C to do so? I'd like to keep my program as
portable as possible, but finally it should run only on a Windows/DOS
machine, so I can also use DOS-only functions if neccessary.


There is no standard method to solve your problem. Standard C provides a
time function which returns a measure of calendar time, but there is
nothing requiring it to be accurate enough for your purposes (and it
probably is not accurate enough) so you will need to leave the realms of
standard C and do something specific to you implementation. For advice
on implementation specific functions you will have to ask in groups
dedicated to the systems you are interested in, such as one of the
microsoft news groups. Although be aware that the best answers for DOS
and Windows are probably significantly different, so you may well have
to decide which you want to target.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Dec 16 '05 #8

P: n/a
Michael Mair wrote:

Dominik Wallner wrote:

Currently I'm using (clock()/float(CLK_TCK)) as time value, which is

Note: Above, you are using float; consider using double if
you want to be sure to have more than six significant digits.


For floating types, consider using double,
unless you have a special reason not to.

--
pete
Dec 16 '05 #9

P: n/a
Dominik Wallner wrote:

I'm currently implementing a program which measures voltages
through an external USB-AD-converter. It should output those
values as time/voltage pairs.

My problem is to measure the time to output (time elapsed since
program start would do just fine) - it should be as precise as
possible, as there may be only differences in milliseconds
between two measurements.

Currently I'm using (clock()/float(CLK_TCK)) as time value,
which is not accurat enough as I get something like:
.... snip ...
So I need a more precise way of measuring time differences. What
functions are available in C to do so? I'd like to keep my
program as portable as possible, but finally it should run only
on a Windows/DOS machine, so I can also use DOS-only functions
if neccessary.


You are out of luck on this newsgroup, which deals only with the
portable standard C languages. That provides no guarantees about
clock resolution etc. For non-portable solutions for your
particular systems find a group that deals with your system. Such
things are off-topic here.

I expect you will get the best results from a DJGPP installation
under DOS/Windows.

--
Some useful references about C:
<http://www.ungerhu.com/jxh/clc.welcome.txt>
<http://www.eskimo.com/~scs/C-faq/top.html>
<http://benpfaff.org/writings/clc/off-topic.html>
<http://anubis.dkuug.dk/jtc1/sc22/wg14/www/docs/n869/> (C99)
<http://www.dinkumware.com/refxc.html> (C-library}
<http://gcc.gnu.org/onlinedocs/> (GNU docs)
Dec 16 '05 #10

P: n/a
> Please read <http://cfaj.freeshell.org/google/>.

ok, sorry for the lack of quotes. I used the google groups reply and
was hoping that would take care of putting it on context.
gettimeofday() is not standard C. In fact, it's defined by the POSIX
standard, and since the OP is using a Windows/DOS environment, it's
likely not to be available.


I'm not aware of a standard C function to provide what the OP was
looking for. gettimeofday() whether or not its standard, will provide
what the OP is looking for, provided their development environment
provides it. its at least a chance of solving the OP problem.

Dec 17 '05 #11

P: n/a
> There are two horrible errors in your post

horrible? :-)
You provide no context for your "answer." I attribute this to your
not knowing how to use groups.google.com correctly
sorry. was using google groups to post and figured it would handle
associating the reply with the post and properly disseminating the
reply to maintain that association.
You provide an "answer" that uses a function that is not part of the
standard C programming language. gettimeofday() has no definition in C.


I'm not aware of a standard call to do what the OP was asking for. I
provided this as a suggestion for the OP to try in case they're lucky
enough to have the function. In contrast with your reply which
provides no help to the OP. Granted, I can't argue with your "horrible
issues" all that much, but at least it was trying to provide some help.

Dec 17 '05 #12

P: n/a
"coder1024" <co*******@gmail.com> writes:
Please read <http://cfaj.freeshell.org/google/>.
ok, sorry for the lack of quotes. I used the google groups reply and
was hoping that would take care of putting it on context.


And the lack of attribution, which Google does provide if you use it
properly.
gettimeofday() is not standard C. In fact, it's defined by the POSIX
standard, and since the OP is using a Windows/DOS environment, it's
likely not to be available.


I'm not aware of a standard C function to provide what the OP was
looking for.


There isn't one.
gettimeofday() whether or not its standard, will provide
what the OP is looking for, provided their development environment
provides it. its at least a chance of solving the OP problem.


The OP said he was using DOS/Windows, which most likely doesn't
provide gettimeofday(). A redirection to an appropriate newsgroup is
far more likely to be helpful.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Dec 17 '05 #13

P: n/a
> So I need a more precise way of measuring time differences. What
functions are available in C to do so? I'd like to keep my program as
portable as possible


You might want to consider looking at the Apache Portable Runtime
project (http://apr.apache.org/). Since portability is a concern this
might provide a nice C library to handle your time needs and other
issues you may come across as you continue your development.

For the specific time issue you've posted about, see the apr_time_now()
function in their time functions module
(http://apr.apache.org/docs/apr/group..._time.html#ga6)

apr_time_t apr_time_now (void) ;

where apr_time_t is microseconds since epoch. this may be better than
gettimeofday() as I originally suggested, since APR runs on a very wide
variety of platforms, where it might be hit and miss wrt whether or not
your platform/environment provides gettimeofday().

Of course, this isn't part of the standard language, but the APR does
provide a very portable set of C functions and so might be of value to
you.

Dec 17 '05 #14

P: n/a

Keith Thompson wrote:
ok, sorry for the lack of quotes. I used the google groups reply and
was hoping that would take care of putting it on context.


And the lack of attribution, which Google does provide if you use it
properly.


well, google provides 2 ways of replying. as I've now discovered,
clicking the reply which opens the text field right on the page doesn't
provide the quoting or attribution. doing the full, separate page
reply does. so I guess I'm due for another 100 lashes. well, now I
know.

Keith Thompson wrote:
gettimeofday() is not standard C. In fact, it's defined by the POSIX
standard, and since the OP is using a Windows/DOS environment, it's
likely not to be available.


I'm not aware of a standard C function to provide what the OP was
looking for.


There isn't one.


which would suggest the OP will need to look to a non-standard
solution.

Keith Thompson wrote:
gettimeofday() whether or not its standard, will provide
what the OP is looking for, provided their development environment
provides it. its at least a chance of solving the OP problem.


The OP said he was using DOS/Windows, which most likely doesn't
provide gettimeofday(). A redirection to an appropriate newsgroup is
far more likely to be helpful.


you're probably right. see my later reply. I think the OP could be
well served by checking out the APR.

Dec 17 '05 #15

P: n/a
coder1024 wrote
(in article
<11**********************@z14g2000cwz.googlegroups .com>):

Keith Thompson wrote:
ok, sorry for the lack of quotes. I used the google groups reply and
was hoping that would take care of putting it on context.


And the lack of attribution, which Google does provide if you use it
properly.


well, google provides 2 ways of replying. as I've now discovered,
clicking the reply which opens the text field right on the page doesn't
provide the quoting or attribution. doing the full, separate page
reply does. so I guess I'm due for another 100 lashes. well, now I
know.


Learning from past mistakes is a really good sign. :-)

I'm not aware of a standard C function to provide what the OP was
looking for.


There isn't one.


which would suggest the OP will need to look to a non-standard
solution.


Precisely. Such a solution is off-topic in this newsgroup, but
decidedly on-topic in newsgroups populated with people familiar
with his platform. Here's the conundrum. If you answer an
off-topic question in a newsgroup, there is the possibility that
you are correct, in which case you do some good. There is also
the possibility that you are incorrect, in which case you do no
good at all, may make the OP waste valuable time on a
non-solution, and clutter up the group with OT-posts. As we now
know, your original response was of the latter variety.

Note that in a group where the response is on-topic, there are a
lot of people fluent and willing to respond in the case of
answers good and bad. Here, you may only get one answer, and it
very well might be wrong.

So, redirecting to an appropriate group is obviously a much
better path.

--
Randy Howard (2reply remove FOOBAR)
"The power of accurate observation is called cynicism by those
who have not got it." - George Bernard Shaw

Dec 17 '05 #16

P: n/a

Randy Howard wrote:
Precisely. Such a solution is off-topic in this newsgroup, but
decidedly on-topic in newsgroups populated with people familiar
with his platform. Here's the conundrum. If you answer an
off-topic question in a newsgroup, there is the possibility that
you are correct, in which case you do some good. There is also
the possibility that you are incorrect, in which case you do no
good at all, may make the OP waste valuable time on a
non-solution, and clutter up the group with OT-posts. As we now
know, your original response was of the latter variety.
yes, there's always the possibility that a reply will not completely
solve the poster's problem or that it could be incorrect. thats
probably not a reason to avoid trying to provide some help. I've used
gettimeofday() a number of times and found it to work and felt it would
at least provide the OP with something to try. it would be a fairly
quick thing for the OP to check and see if they can use that function.
plus, there are probably a lot of readers who would be on platforms
where this is provided and so even if it didn't solve the OP problem it
could solve the next persons problem when searching for an answer.

at any rate, back to the OP's topic, I think something like APR would
probably be a good option.
So, redirecting to an appropriate group is obviously a much
better path.


the OP was provided with re-directions by other posters. I was trying
to provide a thread to pull which I felt might solve their problem.

Dec 17 '05 #17

P: n/a
coder1024 wrote:

You might want to consider looking at the Apache Portable Runtime
project (http://apr.apache.org/). Since portability is a concern this
might provide a nice C library to handle your time needs and other
issues you may come across as you continue your development.

For the specific time issue you've posted about, see the apr_time_now()
function in their time functions module
(http://apr.apache.org/docs/apr/group..._time.html#ga6)

apr_time_t apr_time_now (void) ;

where apr_time_t is microseconds since epoch. this may be better than
gettimeofday() as I originally suggested, since APR runs on a very wide
variety of platforms, where it might be hit and miss wrt whether or not
your platform/environment provides gettimeofday().

Of course, this isn't part of the standard language, but the APR does
provide a very portable set of C functions and so might be of value to
you.


Thank you for that hints! I'll take a look at that, but as this seems to
be a rather big library (and I don't want that much dependencies of my
code) I may or may not find it useful.

Thank you anyway!
Yours,
Dominik Wallner
Dec 17 '05 #18

P: n/a
pete wrote:
Michael Mair wrote:
Dominik Wallner wrote:


Currently I'm using (clock()/float(CLK_TCK)) as time value, which is


Note: Above, you are using float; consider using double if
you want to be sure to have more than six significant digits.


For floating types, consider using double,
unless you have a special reason not to.


Indeed. Just got tired of preaching it all the time ;-)

-Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Dec 17 '05 #19

P: n/a
coder1024 wrote:
Randy Howard wrote:


<snip>
So, redirecting to an appropriate group is obviously a much
better path.


the OP was provided with re-directions by other posters. I was trying
to provide a thread to pull which I felt might solve their problem.


The point is you have ABSOLUTELY NO CLUE as to what might be helpful to
the OP and your suggestion of gettimeofday I can say quite categorically
is of ABSOLUTELY NO HELP and so a COMPLETE waste of everyone's time.
Hence, if you actually know the platform you can point the poster in the
right direction AND tell them to go to a more appropriate group
(suggesting a solution without redirecting them is inappropriate), but
if you don't know the platform the ONLY thing you can sensibly do is
tell them to go to a more appropriate group.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Dec 17 '05 #20

P: n/a

Dominik Wallner wrote:
Thank you for that hints! I'll take a look at that, but as this seems to
be a rather big library (and I don't want that much dependencies of my
code) I may or may not find it useful.


good luck! hope you can get it resolved :-)

Dec 17 '05 #21

P: n/a

Flash Gordon wrote:
the OP was provided with re-directions by other posters. I was trying
to provide a thread to pull which I felt might solve their problem.


The point is you have ABSOLUTELY NO CLUE as to what might be helpful to
the OP and your suggestion of gettimeofday I can say quite categorically
is of ABSOLUTELY NO HELP and so a COMPLETE waste of everyone's time.
Hence, if you actually know the platform you can point the poster in the
right direction AND tell them to go to a more appropriate group
(suggesting a solution without redirecting them is inappropriate), but
if you don't know the platform the ONLY thing you can sensibly do is
tell them to go to a more appropriate group.


gettimeofday() will work very well if available in the OP's development
environment. the OP didn't provide specifics as to their environment.
I do know the platform. I've developed SW on Windows using cygwin and
gcc and successfully used gettimeofday() when in a similar situation
which is why I suggested it. I've also developed using Visual C++. I
don't know about other environments (Borland C++, etc.). Anyway, the
OP can take 2 minutes to try and call the function and will immediately
know if it isn't there. This is more helpful than your ranting. I
mean, really, did you just get out of bed on the wrong side this
morning? Dare I say... relax? :-)

Regardless, there's also the APR which will almost certainly be
available on the OP's platform if they want to put in the effort to add
a product to their environment and dependencies list.

Dec 17 '05 #22

P: n/a
Dominik Wallner wrote:
coder1024 wrote:
<snip>
For the specific time issue you've posted about, see the apr_time_now()
function in their time functions module
(http://apr.apache.org/docs/apr/group..._time.html#ga6)

apr_time_t apr_time_now (void) ;

where apr_time_t is microseconds since epoch. this may be better than


<snip>

Note that the documentation does not, that I could see, does not specify
an accuracy, so it could well on a C implementation where time() is
accurate to 1 second just return a value accurate to 1 second, with the
scaling to milliseconds and the defined epoch just being to make the
interface consistent rather than to guarantee a given accuracy.

Remember that the APR is basically there to support web appications and
they don't generally require sub-second accuracy on time.
Thank you for that hints! I'll take a look at that, but as this seems to
be a rather big library (and I don't want that much dependencies of my
code) I may or may not find it useful.


Go over to the DOS/Windows groups and you are likely to get much more
helpful replies from people who actually know what facilities are
provided by the systems to support your requirements.
-
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Dec 17 '05 #23

P: n/a
Flash Gordon wrote:
Dominik Wallner wrote:
coder1024 wrote:


<snip>
For the specific time issue you've posted about, see the apr_time_now()
function in their time functions module
(http://apr.apache.org/docs/apr/group..._time.html#ga6)

apr_time_t apr_time_now (void) ;

where apr_time_t is microseconds since epoch. this may be better than
<snip>

Note that the documentation does not, that I could see, does not specify
an accuracy, so it could well on a C implementation where time() is
accurate to 1 second just return a value accurate to 1 second, with the
scaling to milliseconds and the defined epoch just being to make the
interface consistent rather than to guarantee a given accuracy.

Remember that the APR is basically there to support web appications and
they don't generally require sub-second accuracy on time.


Having checked what apr_time_now does, and checked the Windows
documentation, apr_time_now is definitely NOT suitable if you want to
know time differences, because the functions it uses are ones MS says
NOT to use for time differences.

Yet another perfect example of why system specific questions should not
be answered by people who do not know the system, and why they should be
redirected to appropriate groups.
Thank you for that hints! I'll take a look at that, but as this seems to
be a rather big library (and I don't want that much dependencies of my
code) I may or may not find it useful.


<snip>

You won't find it useful because it does not solve your problem. There
are correct solutions for Windows and DOS, but someone like Dominik
Wallner is completely unqualified to provide them and is likely to keep
sending you looking at things of no use to you.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Dec 17 '05 #24

P: n/a

Flash Gordon wrote:
For the specific time issue you've posted about, see the apr_time_now()
function in their time functions module
(http://apr.apache.org/docs/apr/group..._time.html#ga6)

apr_time_t apr_time_now (void) ;

where apr_time_t is microseconds since epoch. this may be better than

Having checked what apr_time_now does, and checked the Windows
documentation, apr_time_now is definitely NOT suitable if you want to
know time differences, because the functions it uses are ones MS says
NOT to use for time differences.

Yet another perfect example of why system specific questions should not
be answered by people who do not know the system, and why they should be
redirected to appropriate groups.


The apr_time_now() function retrieves the current system time from
Windows in a FILETIME structure. The MS documentation
(http://msdn.microsoft.com/library/de...letime_str.asp)
for the FILETIME structure says, "It is not recommended that you add
and subtract values from the FILETIME structure to obtain relative
times". It goes on to say that you should instead copy the structure
data into a 64-bit variable and use normal 64-bit arithmetic on it.
Which is exactly what APR does in the FileTimeToAprTime() function.

Granted, the OP doesn't need to worry about this. They should be able
to just call apr_time_now and get what they want and from what I can
tell it should work fine for them on Windows.
Thank you for that hints! I'll take a look at that, but as this seems to
be a rather big library (and I don't want that much dependencies of my
code) I may or may not find it useful.


<snip>

You won't find it useful because it does not solve your problem. There
are correct solutions for Windows and DOS, but someone like Dominik
Wallner is completely unqualified to provide them and is likely to keep
sending you looking at things of no use to you.
--


The apr_time_now() will solve the OP problem if they're willing and
want to add a dependency to their code and take the time to go download
it, etc. They can also do a quick try at using gettimeofday() to see
if its avaiable. Or they can go to another newsgroup and ask further.

Sounds like 3 alternatives and hopefully the OP is better off than when
they originally posted, which is really the point right?

Dec 17 '05 #25

P: n/a
coder1024 wrote:
Flash Gordon wrote:
the OP was provided with re-directions by other posters. I was trying
to provide a thread to pull which I felt might solve their problem. The point is you have ABSOLUTELY NO CLUE as to what might be helpful to
the OP and your suggestion of gettimeofday I can say quite categorically
is of ABSOLUTELY NO HELP and so a COMPLETE waste of everyone's time.
Hence, if you actually know the platform you can point the poster in the
right direction AND tell them to go to a more appropriate group
(suggesting a solution without redirecting them is inappropriate), but
if you don't know the platform the ONLY thing you can sensibly do is
tell them to go to a more appropriate group.


gettimeofday() will work very well if available in the OP's development
environment. the OP didn't provide specifics as to their environment.
I do know the platform. I've developed SW on Windows using cygwin and
gcc and successfully used gettimeofday() when in a similar situation
which is why I suggested it. I've also developed using Visual C++. I
don't know about other environments (Borland C++, etc.). Anyway, the
OP can take 2 minutes to try and call the function and will immediately
know if it isn't there.


The sensible way to implement gettimeofday would be to use a function MS
SPECIFICALLY recommend against using for measuring time differences
during the execution of a program. Are you claiming to know that on the
implementations that provide it as an EXTENSION do not implement it in
the obvious way, or are you claiming to know more about programming for
Windows than MS?

For the record, I actually have an MSDN subscription, and I have been
reading the documentation, so I *know* that the solutions you are
recommending are *not* the appropriate solutions to use.
This is more helpful than your ranting. I
mean, really, did you just get out of bed on the wrong side this
morning? Dare I say... relax? :-)
No, your suggestions are NOT helpful because they are NOT the best way
to achieve the OPs aims. It is the fact that you are insisting that you
are providing helpful information when you are actually suggesting
solutions that are inappropriate to the OPs problem.
Regardless, there's also the APR which will almost certainly be
available on the OP's platform if they want to put in the effort to add
a product to their environment and dependencies list.


That, as I stated in another post, is NOT an appropriate solution. I
know this because I read the source code and checked the functions it
uses in MSDN. So again, unless you know more about the correct calls to
use in Microsoft Windows than Microsoft do you are giving BAD advice.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Dec 17 '05 #26

P: n/a

Flash Gordon wrote:
Regardless, there's also the APR which will almost certainly be
available on the OP's platform if they want to put in the effort to add
a product to their environment and dependencies list.


That, as I stated in another post, is NOT an appropriate solution. I
know this because I read the source code and checked the functions it
uses in MSDN. So again, unless you know more about the correct calls to
use in Microsoft Windows than Microsoft do you are giving BAD advice.


See my other reply. The APR function calls Windows APIs which can be
used to compare times. The MS documentation simply says you shouldn't
directly compare the times in the structure but you should first
convert to a 64-bit variable and then to normal 64-bit arithmetic on
that. From what I saw, apr_time_now will work just fine for giving
relative times. Which MS documentation are you referring to which
indicates otherwise? I'm not saying its not there, just that the APR
source and MS documentation I looked through don't seem to agree with
what you're saying.

Dec 17 '05 #27

P: n/a
"coder1024" <co*******@gmail.com> writes:
Flash Gordon wrote:
> Regardless, there's also the APR which will almost certainly be
> available on the OP's platform if they want to put in the effort to add
> a product to their environment and dependencies list.


That, as I stated in another post, is NOT an appropriate solution. I
know this because I read the source code and checked the functions it
uses in MSDN. So again, unless you know more about the correct calls to
use in Microsoft Windows than Microsoft do you are giving BAD advice.


See my other reply. The APR function calls Windows APIs which can be
used to compare times. The MS documentation simply says you shouldn't
directly compare the times in the structure but you should first
convert to a 64-bit variable and then to normal 64-bit arithmetic on
that. From what I saw, apr_time_now will work just fine for giving
relative times. Which MS documentation are you referring to which
indicates otherwise? I'm not saying its not there, just that the APR
source and MS documentation I looked through don't seem to agree with
what you're saying.


And now here we are arguing about what Microsoft's documentation says.

This is exactly why we try to discourage off-topic discussions here.
I don't know which of you is correct about the Windows APIs. There
are plenty of people who would know, and they hang out in the Windows
newsgroups, which is where this discusssion should be happening.

If the OP had simply been redirected to a Windows or DOS newsgroup in
the first place, he'd probably already have a good (but
system-specific) solution, and we would have had more time to spend
discussing the C programming language, which is the topic of this
newsgroup.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Dec 17 '05 #28

P: n/a
On 17 Dec 2005 06:00:46 -0800, in comp.lang.c , "coder1024"
<co*******@gmail.com> wrote:

gettimeofday() will work very well if available in the OP's development
environment.
But the points are
a) you have no clue whether it is available, so may have egregiously
misled the OP

b) even if a function with tht name were available, it might return
something totally different to what you expect eg "around noon, I
think" or the number of femtoseconds since 3rd February 2000.

c) whether it may or may not exist, still doesn't make it topical
here, and here there's almost nobody able to properly correct you if
you're talking bullshit.
OP can take 2 minutes to try and call the function and will immediately
know if it isn't there.
How? Call it? What if he needs a specific header? What if he needs to
install a package he hasn't installed yet? What if he needs a special
coimpiler option? Plus see point b above.
This is more helpful than your ranting.
Was it more helpful than redirecting the OP to a group where he could
get a definitively correct answer, plus lots of other correct answers
to other questions he will probably have later?
Regardless, there's also the APR


I have no idea what this is, but unless its defined in the ISO C
Standard its also offtopic here.

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Dec 17 '05 #29

P: n/a

Keith Thompson wrote:
"coder1024" <co*******@gmail.com> writes:
This is exactly why we try to discourage off-topic discussions here.
I don't know which of you is correct about the Windows APIs. There
are plenty of people who would know, and they hang out in the Windows
newsgroups, which is where this discusssion should be happening.
Well, the Windows API documentation is easily accessible on the web, so
its pretty trivial to verify. The whole dive into the Windows API
discussion was definitely off-topic for this forum, but it was only
done in response to the claim that using the APR time function
reccomended wouldn't work and used APIs which MS did not reccomend for
use in figuring out relative times. See
http://msdn.microsoft.com/library/de...letime_str.asp
for more info on this if you're curious.

I believe we're left with at least 3 choices for the OP:

1) gettimeofday() which may or may not be available; quick test to find
this out
2) APR which adds dependencies, but which should provide the time delta
needed
3) go to another newsgroup and ask the question again there
If the OP had simply been redirected to a Windows or DOS newsgroup in
the first place, he'd probably already have a good (but
system-specific) solution, and we would have had more time to spend
discussing the C programming language, which is the topic of this
newsgroup.


they were directed to another newsgroup. they were also provided with
a couple suggestions on how to solve their problem.

Dec 17 '05 #30

P: n/a

Mark McIntyre wrote:
gettimeofday() will work very well if available in the OP's development
environment.
But the points are
a) you have no clue whether it is available, so may have egregiously
misled the OP


no, I think you're being a little dramatic there. the OP should be
able to very quickly determine if its available in their environment.
if its not, no loss. if its is, their problem has just been solved.
actually if it isn't they could also try the APR alternative presented.
b) even if a function with tht name were available, it might return
something totally different to what you expect eg "around noon, I
think" or the number of femtoseconds since 3rd February 2000.
if its available, its should be a trivial matter to do a sanity check
that you're getting good data back. since the OP is interested in time
deltas, I don't think it matters what the "0" time is based on.
c) whether it may or may not exist, still doesn't make it topical
here, and here there's almost nobody able to properly correct you if
you're talking bullshit.
I believe gettimeofday() might work for the OP (depending on their
environment) and APR will work for them which is why I posted the info.
I wasn't BS'ing. I was trying to provide some assistance.
Was it more helpful than redirecting the OP to a group where he could
get a definitively correct answer, plus lots of other correct answers
to other questions he will probably have later?


Re-directing the OP to another group is fine. I'm not arguing with
that. I just provided some possible solutions for the OP to try.
Regardless, there's also the APR


I have no idea what this is, but unless its defined in the ISO C
Standard its also offtopic here.


The Apache Portable Runtime (APR) is a C runtime library designed to
provide a number of lower level basic functions for developers. See
http://apr.apache.org/ for more info. It was posted here because I
felt it might be a good alternative for the OP to try in order to solve
their problem if they didn't have gettimeofday() available.

Dec 17 '05 #31

P: n/a
coder1024 wrote:
Flash Gordon wrote: the OP didn't provide specifics as to their environment.
I do know the platform.


What part of 'but finally it should run only on a Windows/DOS machine',
from the original post, did you not understand?
Dec 17 '05 #32

P: n/a

Martin Ambuhl wrote:
coder1024 wrote:
Flash Gordon wrote:

the OP didn't provide specifics as to their environment.
I do know the platform.


What part of 'but finally it should run only on a Windows/DOS machine',
from the original post, did you not understand?


By environment I was referring to compiler. For example, if you're
using gcc/cygwin on Windows you could use the gettimeofday() function.
But, under Visual C++ the function is not available.

Dec 17 '05 #33

P: n/a
coder1024 wrote:
Flash Gordon wrote:
Regardless, there's also the APR which will almost certainly be
available on the OP's platform if they want to put in the effort to add
a product to their environment and dependencies list.

That, as I stated in another post, is NOT an appropriate solution. I
know this because I read the source code and checked the functions it
uses in MSDN. So again, unless you know more about the correct calls to
use in Microsoft Windows than Microsoft do you are giving BAD advice.


See my other reply. The APR function calls Windows APIs which can be
used to compare times. The MS documentation simply says you shouldn't
directly compare the times in the structure but you should first
convert to a 64-bit variable and then to normal 64-bit arithmetic on
that. From what I saw, apr_time_now will work just fine for giving
relative times. Which MS documentation are you referring to which
indicates otherwise? I'm not saying its not there, just that the APR
source and MS documentation I looked through don't seem to agree with
what you're saying.


Cut from the current documentation my company pays for me to have:
| The system can periodically refresh the time by synchronizing with a
| time source. Because the system time can be adjusted either forward or
| backward, do not compare system time readings to determine elapsed
| time.

It goes on to suggest where to look for functions which should be used
for measuring elapsed time during program execution.

BTW, *plonk*, since I don't want to be discussing one of the many
specific systems I program here.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Dec 17 '05 #34

P: n/a
Keith Thompson wrote:

<snip>
And now here we are arguing about what Microsoft's documentation says.

This is exactly why we try to discourage off-topic discussions here.


<snip>

Sorry Keith, and the rest of the group. I normally manage to avoid
letting erroneous off topic advice tempt me in to a debate, but I've now
plonked coder1024, so this won't be debated further by me.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Dec 17 '05 #35

P: n/a
One way of doing that (under an x86 and in standard C)
is:

#include <stdio.h>
long long (*rdtsc)(void);

int main(void)
{
unsigned char fn[] = {0xf,0x31,0xc3};
rdtsc = (long long(*)(void)) fn;
long long cycles = rdtsc();
printf("Cycles since machine start = %lld\n",cycles);
return 0;
}

That function will return the number of cycles
since the CPU started, expressed as a 64 bit number.

At 2GHZ that makes for an EXTREMELY accurate and reliable timer.

The only problem with it is that the CPU keeps counting cycles
when your program is NOT running but it has been swapped out
and is inactive.

If your machine is slightly loaded, this will work quite OK.
jacob

Dec 17 '05 #36

P: n/a
In a non C99 compatible compiler like msvc that should be:
#include <stdio.h>
__int64 (*rdtsc)(void);

int main(void)
{
unsigned char fn[] = {0xf,0x31,0xc3};
__int64 cycles;
rdtsc = (__int64(*)(void)) fn;
cycles = rdtsc();
printf("Cycles since machine start = %I64d\n",cycles);
return 0;
}

The "fn" values are:
0xf 0x31: rdtsc instruction.
0xc3 return

The rdtsc instruction leaves the 64 bit value of the time stamp counter
in EAX:EDX.

Normally you would be interested in the difference between
two calls.

Dec 17 '05 #37

P: n/a
On 17 Dec 2005 11:10:51 -0800, in comp.lang.c , "coder1024"
<co*******@gmail.com> wrote:

Mark McIntyre wrote:
a) you have no clue whether it is available, so may have egregiously
misled the OP
no, I think you're being a little dramatic there. the OP should be
able to very quickly determine if its available in their environment.


Bollocks. And if you can't see why, you're probably also incapable of
understanding the other arguments that have been made to you.
if its available, its should be a trivial matter to do a sanity check
that you're getting good data back. since the OP is interested in time
deltas, I don't think it matters what the "0" time is based on.
And if it returns "A quarter past the eleventh hour, since you ask",
or "slightly before noon, my good fellow"?
I wasn't BS'ing. I was trying to provide some assistance.


You miss the point entirely. You failed in the latter, and are now
persisting in ignoring polite (though increasingly less polite)
requests to stop it.
>Regardless, there's also the APR


I have no idea what this is, but unless its defined in the ISO C
Standard its also offtopic here.


The Apache Portable Runtime (APR) is


I know that you dolt. I don't give two hoots. Its not topical here, so
here I know nothing of it. Stop wittering on about it.
----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Dec 17 '05 #38

P: n/a
jacob navia said:
In a non C99 compatible compiler like msvc that should be:
#include <stdio.h>
__int64 (*rdtsc)(void);

int main(void)
{
unsigned char fn[] = {0xf,0x31,0xc3};
__int64 cycles;
rdtsc = (__int64(*)(void)) fn;
cycles = rdtsc();
printf("Cycles since machine start = %I64d\n",cycles);
return 0;
}


foo.c:2: parse error before `*'
foo.c:2: warning: type defaults to `int' in declaration of `__int64'
foo.c:2: `__int64' declared as function returning a function
foo.c:2: ANSI C forbids data definition with no type or storage class
foo.c: In function `main':
foo.c:7: `__int64' undeclared (first use in this function)
foo.c:7: (Each undeclared identifier is reported only once
foo.c:7: for each function it appears in.)
foo.c:7: parse error before `cycles'
foo.c:8: `rdtsc' undeclared (first use in this function)
foo.c:8: `__int64' used prior to declaration
foo.c:8: warning: implicit declaration of function `__int64'
foo.c:8: parse error before `)'
foo.c:9: `cycles' undeclared (first use in this function)
foo.c:9: `rdtsc' used prior to declaration
foo.c:9: warning: implicit declaration of function `rdtsc'
foo.c:10: warning: unknown conversion type character `I' in format
foo.c:10: warning: too many arguments for format
foo.c:6: warning: unused variable `fn'

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Dec 17 '05 #39

P: n/a
I said that that program was for msvc like compilers. For gnuish
compilers use:
[root@gateway root]# uname -a
Linux gateway 2.4.18-6mdk #1 Fri Mar 15 02:59:08 CET 2002 i586 unknown
[root@gateway root]# cat rdtsc.c
#include <stdio.h>
long long (*rdtsc)(void);

int main(void)
{
unsigned char fn[] = {0xf,0x31,0xc3};
long long cycles;
rdtsc = (long long(*)(void)) fn;
cycles = rdtsc();
printf("Cycles since machine start = %lld\n",cycles);
return 0;
}
[root@gateway root]# gcc rdtsc.c
[root@gateway root]# ./a.out
Cycles since machine start = 7045896211955
[root@gateway root]#

Dec 17 '05 #40

P: n/a

Flash Gordon wrote:
| The system can periodically refresh the time by synchronizing with a
| time source. Because the system time can be adjusted either forward or
| backward, do not compare system time readings to determine elapsed
| time.


yes, good point. however, if you're in control of the system time the
methods already presented should work fine. guess it depends on how
the user's system is setup.

Dec 17 '05 #41

P: n/a
On Sat, 17 Dec 2005 23:05:30 +0100, in comp.lang.c , jacob navia
<ja***@jacob.remcomp.fr> wrote:
I said that that program was for msvc like compilers. For gnuish
compilers use:


(some highly nonportable and offtopic stuff)
----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Dec 17 '05 #42

P: n/a

Flash Gordon wrote:
Sorry Keith, and the rest of the group. I normally manage to avoid
letting erroneous off topic advice tempt me in to a debate


My intent was simply to provide some help to the OP. I apologize if
this was not done correctly.

Dec 17 '05 #43

P: n/a
Mark McIntyre wrote:
On Sat, 17 Dec 2005 23:05:30 +0100, in comp.lang.c , jacob navia
<ja***@jacob.remcomp.fr> wrote:

I said that that program was for msvc like compilers. For gnuish
compilers use:

(some highly nonportable and offtopic stuff)
----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----


Portability:

That program will run under:

Windows (all versions)
Linux (all x86 versions)
Solaris (x86 versions)
BeOs

That is almost 80-90% of the market... Maybe 100% when
you consider that it has been designed for the future
x86 MAc OS. :-)

This is meant as a demonstration of the power of C.

I bet there is no other language that manages doing
something like this with that kind of easy.

jacob

Dec 17 '05 #44

P: n/a

Mark McIntyre wrote:
no, I think you're being a little dramatic there. the OP should be
able to very quickly determine if its available in their environment.
Bollocks. And if you can't see why, you're probably also incapable of
understanding the other arguments that have been made to you.


No, I understand the arguments being presented quite well. There's the
opinion that the OP should simply be referred to another group. Thats
fine with me, however, I thought it would also be good to give the OP a
couple threads to pull which I thought might help. I really doubt that
was worth some of the responses received. Figuring out whether or not
you have the function available takes adding sys/time.h, adding a call,
and trying to compile.
You miss the point entirely. You failed in the latter, and are now
persisting in ignoring polite (though increasingly less polite)
requests to stop it.


I think a few people need to get some fresh air.
I have no idea what this is, but unless its defined in the ISO C
Standard its also offtopic here.


The Apache Portable Runtime (APR) is


I know that you dolt. I don't give two hoots. Its not topical here, so
here I know nothing of it. Stop wittering on about it.


I only posted it as I thought it might be of use to the OP.

Dec 17 '05 #45

P: n/a
In article <11**********************@g14g2000cwa.googlegroups .com>
coder1024 <co*******@gmail.com> wrote (in part):
The Apache Portable Runtime (APR) is a C runtime library designed to
provide a number of lower level basic functions for developers. See
http://apr.apache.org/ for more info.


Being the generally curious sort, I took a look at the URL above.
Besides not working at all in lynx, the documentation appears to
be largely nonexistent. But it does appear that the goal of the
time routines in the APR library is to support the "time of day"
notion, as used to tell people what a wall clock reads, similar
to the "struct tm" values from localtime() and gmtime().

These are not necessarily what one wants at all. In particular,
consider the way an accurate clock mounted on a wall will read around
the time when most of the USA transitions into or out of Daylight
Saving Time:

01:59:57
01:59:58
01:59:59
01:00:00
01:00:01
...

Or:

01:59:58
01:59:59
03:00:00

Instead of one second elapsing, one hour and one second suddenly
elapses (in the second case). In the first case, time actually
goes backwards!

Besides DST, one may have to deal with leap-seconds, in which there
is an xx:59:60. For these reasons, Coordinated Universal Time
(UTC) actually comes in three flavors: UTC, UT1, and TAI. See
<http://tycho.usno.navy.mil/leapsec.html> and
<http://tycho.usno.navy.mil/systime.html> for details.

And of course, on computers, we may also be interested in elapsed
CPU time (which is quite different from wall-clock time, especially
in multiprocessing and multiprocessor systems).

(I would write more but it is time to get ready for gym).
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (4039.22'N, 11150.29'W) +1 801 277 2603
email: forget about it http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to spammers.
Dec 17 '05 #46

P: n/a
"coder1024" <co*******@gmail.com> writes:
Mark McIntyre wrote:
>gettimeofday() will work very well if available in the OP's development
>environment.


But the points are
a) you have no clue whether it is available, so may have egregiously
misled the OP


no, I think you're being a little dramatic there. the OP should be
able to very quickly determine if its available in their environment.
if its not, no loss. if its is, their problem has just been solved.
actually if it isn't they could also try the APR alternative presented.


And what if the OP's system happens to have gettimeofday() (perhaps
because Cygwin is installed), but other systems on which his code
needs to run don't?

He needs to measure times to high precision. There's no portable way
to do that. He's using a DOS/Windows system (I won't go into the
distinction between DOS and Windows), and presumably doesn't need his
code to be portable to other systems. The obvious answer is to use
some DOS-specific or Windows-specific function. Presumably
gettimeofday() and whatever the APR provides use that function, but
there's probably no good reason for the OP not to use the underlying
function directly.

The OP can find out about this by posting to a system-specific
newsgroup.

I understand that you were trying to help, but very often the best
help you can possibly offer is to say "We don't know, but the folks
over there probably do".

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Dec 17 '05 #47

P: n/a
jacob navia said:
I said that that program was for msvc like compilers.


Well, gcc is an msvc-like compiler, in the sense that it compiles ISO C90
programs just fine, same as msvc does.

Still, I tried your gcc-friendly replacement, and got this:

foo.c:2: warning: ANSI C does not support `long long'
foo.c: In function `main':
foo.c:7: warning: ANSI C does not support `long long'
foo.c:8: warning: ANSI C does not support `long long'
foo.c:10: warning: ANSI C does not support the `ll' length modifier

If I tried to squeeze that lot past peer review, I'd be laughed out of the
building.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Dec 18 '05 #48

P: n/a
jacob navia wrote:
Mark McIntyre wrote:
On Sat, 17 Dec 2005 23:05:30 +0100, in comp.lang.c , jacob navia
<ja***@jacob.remcomp.fr> wrote:
I said that that program was for msvc like compilers. For gnuish
compilers use:
(some highly nonportable and offtopic stuff)


<snip sig, and please snip peoples sigs if you are not commenting on them>
Portability:

That program will run under:

Windows (all versions)
Linux (all x86 versions)
Solaris (x86 versions)
BeOs
It won't work on the AIX box I use regularly, nor on the big AIX server
one of our customers has recently bought (even if they put Linux on it),
nor on my iMac running Linux, nor on my brothers notebook...

I've no idea if it will work on SCO, and I doubt you do either (yes, SCO
is still going). It won't work on the non-x86 version of Solaris.
That is almost 80-90% of the market... Maybe 100% when
you consider that it has been designed for the future
x86 MAc OS. :-)
Should I tell our big customer they need to scrap many thousands of
pounds of investment the have recently made then? Will my brothers
notebook suddenly stop working?

Whatever you might think from your limited experience the code is a very
long way from portable. Your code may will be an appropriate solution to
the OPs problem, but it no-longer belongs here than the discussion of
Windows system calls I mistakenly let myself get dragged in to.
This is meant as a demonstration of the power of C.

I bet there is no other language that manages doing
something like this with that kind of easy.


Assembler, Pascal with extensions (you are not using standard C so this
is a valid comparison), ADA I'm sure (since it is used for embedded
systems), Forth (IIRC), C++ with the same non-standard tricks...
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Dec 18 '05 #49

P: n/a

Keith Thompson wrote:
The obvious answer is to use some DOS-specific or Windows-specific function.
Presumably gettimeofday() and whatever the APR provides use that function, but
there's probably no good reason for the OP not to use the underlying
function directly.
I suppose the advantage of using something like APR instead of calling
the OS API directly would be in the event of the OP wanting to, in the
future, try running their code on a different OS. As long as APR was
provided you could then of course target the other OS and presumably
APR provides a similar call to that OS's appropriate APIs.
The OP can find out about this by posting to a system-specific
newsgroup.

I understand that you were trying to help, but very often the best
help you can possibly offer is to say "We don't know, but the folks
over there probably do".


Point taken.

Dec 18 '05 #50

74 Replies

This discussion thread is closed

Replies have been disabled for this discussion.