473,386 Members | 1,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

problem with clock()

Hello Friends,
I would like to calcute time required by any function
e.g.
start=clock();
scanf("%d",&no);//i enter number & stop for 2 seconds
end=clock()
then i printed 'end -start'
but it gives me answer=0
Guide me for why clock() is not working
I hv FEDORA 6.
Tell me other way to solve my TIME PROBLEM.......
Oct 13 '07 #1
1 2795
arne
315 Expert 100+
Hello Friends,
I would like to calcute time required by any function
e.g.
start=clock();
scanf("%d",&no);//i enter number & stop for 2 seconds
end=clock()
then i printed 'end -start'
but it gives me answer=0
Guide me for why clock() is not working
I hv FEDORA 6.
Tell me other way to solve my TIME PROBLEM.......
I usually use gettimeofday() for timing measurements in C:

Expand|Select|Wrap|Line Numbers
  1. #include <sys/time.h>
  2. ...
  3. struct timeval s, e;
  4. unsigned long tdiff;
  5. gettimeofday( &s, NULL );
  6.  
  7. /* do your stuff here */
  8.  
  9. gettimeofday( &e, NULL );
  10. tdiff = (e.tv_sec-s.tv_sec) * 1000000+(e.tv_usec-s.tv_usec);
  11.  
HTH,
Arne
Oct 13 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: David Li | last post by:
I am having a lot of problem with following code. To start with I have a working sets of code and the top level SystemC code looks like this: ----------working main.cpp start here...
6
by: Marcin Kalicinski | last post by:
Hi all, I have a problem with 'volatile' use in C++. The function get_clocks() below tries to use a 16 bit hardware counter to count time. The counter overflows very often. But an interrupt is...
4
by: Reney | last post by:
I have a very weird problem in updating my datagrid. Please help me to solve it. The datagrid is tied to a dataset table with five columns. Three of them are primary key and the other two columns...
4
by: Shawn Yates | last post by:
I am fairly new to MS Access and VB but thanks to many of the posts on this site I have found solutions to my problems. I have been searching all day, however, for an answer to my current problem...
4
by: Test3456 | last post by:
Hello, i got following Job: Write a programm that shows the letters a - z. The lettes should be act in some millisecounds. Start with 100 millisecounds and every loop the millisecounds show be...
10
by: StephQ | last post by:
I found that old post: http://groups.google.com/group/comp.lang.c++/browse_frm/thread/3a2562c9a5f8998/15519204726d01e8?lnk=gst&q=vector+no+surprise&rnum=2#15519204726d01e8 I just erased the...
7
by: abracadabra | last post by:
I am reading an old book - Programming Pearls 2nd edition recently. It says, "Even though the general C++ program uses 50 times the memory and CPU time of the specialized C program, it requires...
17
by: joebenjamin | last post by:
This is a problem I was trying to help a few friends figure out for fun. I am not sure how to go about this, but there is something I am missing here. Here is what we want the output to be: Need...
12
by: jt2 | last post by:
Hello Perl Gurus! I'm quite a perl neophyte so I'm looking for help understanding why print doesn't print correctly. This may be a totally stupid error.... He is my program. What it is doing...
6
by: fido19 | last post by:
Once upon a time, there lived a chimpanzee called Luycha Bandor (aka Playboy Chimp). Luycha was unhappily married to Bunty Mona, a short but cute little lady chimp. Luycha was tall and handsome –...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.