473,323 Members | 1,589 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,323 software developers and data experts.

Need help to time algorithms in C (msec/usec accuracy)

1
Hi,

I have written two algorithms and need to be compare them in terms of how long each take. I have tried clock() before/after each algorithm but my CLOCKS_PER_SEC variable is defined as 1000 which only gives me accuracy upto 1 msec. I have alo tried time() but this is accurate upto 1 sec. I have tried _ftime() and accessed the msec part but again I am not sure if this is accurate. In some cases I am getting same sec/msec values before and after my algorithm.

What is the best way of determining execution time which is at least semi-reliable and is accurate utp usec level.

Thanks in advance for your help.

Regards,

Junaid.
Feb 25 '08 #1
1 2454
weaknessforcats
9,208 Expert Mod 8TB
You could run the program 100,000 times and divide your elapsed time by 100,000, for example.
Feb 25 '08 #2

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

Similar topics

10
by: point | last post by:
Hi... I have this format 2003-12-01 18:46:20.0 And would like it to be 01-12-2003 18:46:20 I know it can be done vis string cuts and explodes but ther's got to be a better way using time...
18
by: bart_nessux | last post by:
I need a script to call several functions at the same time. How does one call more than one function simultaneously?
1
by: MyHaz | last post by:
What is the running time of conactination on character strings. i.e. >> joe="123" >> joe+="99999999999999999" is it Amortized Constant time? I don't think it would be O((number of...
9
by: HL | last post by:
I am using VS 2005 Beta - C# Problem: The Timer fires a few milliseconds before the actual Due-Time Let's say a timer is created in the following manner: System.Threading.Timer m_timer = null;...
33
by: ram.ragu | last post by:
hi i have problem to calculate idle time of cpu and if idle time is more then i have to shut down the system. can anyone tell me the idea to so that please
3
by: jm.suresh | last post by:
I am trying to measure the time the processor spends on some operation, and I want this measure to not depend on the current load of the machine. But doing the following prints different values...
4
by: Wook | last post by:
Ok I got a set of Forms Reports etc it goes like this Reports Form Passes a Filter to the report for the needed results The filter it passes along is fine except one problem I need a way for the...
3
by: youtoo | last post by:
It has been extensively discussed the time complexity (quadratic) of string concatenation (due to string's immutability). But what is: == the time complexity of string indexing? Is it constant?...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.