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

HELP with timing my sorting functions

My professor wants us to get the CPU time for each of the sorting functions that I create. He said that we can use the clock methiod in Visual Studio and gave the code:

long timeElapsed;

timeElapsed= clock();

where timeElapsed depends on the system, and we can use CLOCKS_PER_SEC, which returns how many clock sycles per second it is measuring.

I have no idea how to set this up and cannot find anything in either of my books. Can anyone help? Thank you!!
Oct 29 '07 #1
1 1346
Ganon11
3,652 Expert 2GB
clock() returns a clock_t variable indicating the current time. You can divide this by CLOCKS_PER_SEC to get seconds.

So you need to get the time before the algorithm and the time after the algorithm, so you can have change in clock_t (which is a clock_t variable). Then divide this by CLOCKS_PER_SEC to get seconds elapsed.
Oct 30 '07 #2

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

Similar topics

4
by: dont bother | last post by:
This is really driving me crazy. I have a dictionary feature_vectors{}. I try to sort its keys using #apply sorting on feature_vectors sorted_feature_vector=feature_vectors.keys()...
3
by: praba kar | last post by:
Dear All, I am new to Python. I am in need of some sorting functions (eg) numerical sorting functions and alphapetical sorting functions. I have searched through net But I cannot find any...
22
by: mike | last post by:
If I had a date in the format "01-Jan-05" it does not sort properly with my sort routine: function compareDate(a,b) { var date_a = new Date(a); var date_b = new Date(b); if (date_a < date_b)...
1
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am...
2
by: RC | last post by:
http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_sort2 You can see above link or read below i copy/paste from above link <script type="text/javascript"> function sortNumber(a, b)...
1
by: thebrainmore | last post by:
could someone help with my average and sort functions in this program #include <iostream.h> //funtion prototypes int FindLowNum(int , int ); int FindHighNum(int , int);
5
by: Renato | last post by:
I have an array of pointers to class Shape. I create 4 items and display their values. shapes Shape *shapes; shapes = new Shape (p1); shapes = new Triangle (p1); shapes = new Polygon (p2);
3
KevinADC
by: KevinADC | last post by:
If you are entirely unfamiliar with using Perl to sort data, read the "Sorting Data with Perl - Part One and Two" articles before reading this article. Beginning Perl coders may find this article...
0
by: Daniel Fetchinson | last post by:
On 4/15/08, Daniel Fetchinson <fetchinson@googlemail.comwrote: BTW, using the following ###################################################################### # CODE TO TEST BOTH...
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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...

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.