473,494 Members | 1,933 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

how to know the time taken to complete a program?

4 New Member
I want to know how we can calculate the time taken for the compilation of a program...pls help..
Oct 8 '07 #1
15 4323
Ganon11
3,652 Recognized Expert Specialist
Check out this function.
Oct 8 '07 #2
sicarie
4,677 Recognized Expert Moderator Specialist
Check out this function.
You know how to tell when you're too tired to be at work? You look at the URL and think, "What the hell is the C Lock function?" And realize only by noticing 'ctime' that it's "clock".

Okay, let's see if I can get away with sleeping in my cube.
Oct 8 '07 #3
RajuRaman
4 New Member
Check out this function.
Actually i want to know the compilation time of a c++ program...could u pls tell me how can i use the function clock....
Oct 8 '07 #4
r035198x
13,262 MVP
Actually i want to know the compilation time of a c++ program...could u pls tell me how can i use the function clock....
Some compilers are kind enough to tell you such details or maybe you are writing a C++ compiler using C++?
Oct 8 '07 #5
RajuRaman
4 New Member
Some compilers are kind enough to tell you such details or maybe you are writing a C++ compiler using C++?
Ya I am writing a C++ program...and i tried the below program


#include<time.h>
#include<stdio.h>
#include<dos.h>
int main(void)
{
clock_t start , end;
start=clock();
delay(2000);
end= clock();
printf("the time was: %f \n",(end-start/CLK_TCK_;
return 0;
}

but this doesnt give the proper time..its giving the time after i press RUN..
Oct 8 '07 #6
Banfa
9,065 Recognized Expert Moderator Expert
What's your interest in knowing the compilation/link time?

The only times when it has ever been an issue in my carrier it has been acceptable to time it by hand using a trust wrist watch and just noting the approximate start and end times, i.e. normally people only care when the time is long enough to measure inaccurately with knowing the exact start and stop times.
Oct 8 '07 #7
r035198x
13,262 MVP
Ya I am writing a C++ program...and i tried the below program


#include<time.h>
#include<stdio.h>
#include<dos.h>
int main(void)
{
clock_t start , end;
start=clock();
delay(2000);
end= clock();
printf("the time was: %f \n",(end-start/CLK_TCK_;
return 0;
}

but this doesnt give the proper time..its giving the time after i press RUN..
1.) Use code tags when posting code
2.) That won't give you compilation time. Compilation time by the way will be different on different compilers and platforms. You need to give a C++ source file as an argument to a compiler that you have access to so that you then measure the start and stop time of the compilation process that you will have manually started.
Oct 8 '07 #8
RajuRaman
4 New Member
What's your interest in knowing the compilation/link time?

The only times when it has ever been an issue in my carrier it has been acceptable to time it by hand using a trust wrist watch and just noting the approximate start and end times, i.e. normally people only care when the time is long enough to measure inaccurately with knowing the exact start and stop times.
My interest is that..I hav 2 C++ programs....and I want to know which one will take less time...and choose the best between the two...and the time is in milli seconds..which cannot b noted using a wrist watch..
Oct 8 '07 #9
r035198x
13,262 MVP
What's your interest in knowing the compilation/link time?

The only times when it has ever been an issue in my carrier it has been acceptable to time it by hand using a trust wrist watch and just noting the approximate start and end times, i.e. normally people only care when the time is long enough to measure inaccurately with knowing the exact start and stop times.
Only use I can think of it is when one is making a C++ compiler wants to test their compiler's compilation speed.
I'm of the opinion that writing a C++ compiler is actually useless in itself so there.
Oct 8 '07 #10
Banfa
9,065 Recognized Expert Moderator Expert
I'm of the opinion that writing a C++ compiler is actually useless in itself so there.
That rather depends on if you are manufacturing a new processor or not. If you are creating a new processor then not creating a compiler for it is going to somewhat limit it's use :D
Oct 8 '07 #11
r035198x
13,262 MVP
My interest is that..I hav 2 C++ programs....and I want to know which one will take less time...and choose the best between the two...and the time is in milli seconds..which cannot b noted using a wrist watch..
Take a deep breadth.
Now read this:
Compilation time is different from running time.

A fast program is not a program that takes a short time to compile. It is one that takes a short time to run.
Oct 8 '07 #12
r035198x
13,262 MVP
That rather depends on if you are manufacturing a new processor or not. If you are creating a new processor then not creating a compiler for it is going to somewhat limit it's use :D
Thankfully I don't fiddle around with such stuff anymore.
Of course creating a processor is not entirely useless so I take back half of my ealier remark.
Oct 8 '07 #13
Banfa
9,065 Recognized Expert Moderator Expert
A fast program is not a program that takes a short time to compile. It is one that takes a short time to run.
Actually almost certainly the reverse, optimisation takes far longer than actual compilation of the code so if you where to switch off the optimisation in your compiler you will almost certainly end up with a program that compiles faster.

However optimised code almost always runs faster than un-optimised code so if you switch off the optimiser you will almost certainly end up with a program that runs slower.
Oct 8 '07 #14
r035198x
13,262 MVP
Actually almost certainly the reverse, optimisation takes far longer than actual compilation of the code so if you where to switch off the optimisation in your compiler you will almost certainly end up with a program that compiles faster.

However optimised code almost always runs faster than un-optimised code so if you switch off the optimiser you will almost certainly end up with a program that runs slower.
So how is my comment the reverse of this?
Oct 8 '07 #15
Banfa
9,065 Recognized Expert Moderator Expert
So how is my comment the reverse of this?
Sorry I meant your statement did not go far enough, a short compile time is likely to mean a long run time and vice versa.
Oct 8 '07 #16

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

Similar topics

77
4502
by: Charles Law | last post by:
Hi guys I have a time critical process, running on a worker thread. By "time critical", I mean that certain parts of the process must be completed in a specific time frame. The time when the...
4
4341
by: Christine | last post by:
I've implemented a countdown timer for a tutorial web page that should give the user 45 minutes to complete the test, only to find that the timer is slowly 'losing' time. On average, it actually...
1
2529
by: Francesc Guim Bernat | last post by:
Dear colleagues, i'm getting in troubles using one XML library with Visual Studio .NET and Xerces with Xalan. When i execute the code i get the next run time error: "Run-Time Check Failure #2...
6
6893
by: Peter Row | last post by:
Hi, I am writing a DLL in VB.NET that implements IHttpHandler.ProcessRequest. This code calls a sub and I need to know if that sub did a response redirect or not. Specifically I need to know...
16
1451
by: silversurfer2025 | last post by:
Hello everyone, once again, I have a very basic problem in C++, which I was not able to solve (maybe because of my Java-Experience or just because it is always the small syntax-things which break...
6
6373
by: Matik | last post by:
Hi, I have a funny situation. Within: MSSQL 2000 SP3, everything below described is running on same PC. there is a program running, which sends information to two other programs. This...
7
1332
by: =?Utf-8?B?Q2hha3JhdmFydGh5?= | last post by:
Today, after watching the presentation by Amanda Silver at http://channel9.msdn.com/Showpost.aspx?postid=335058 , from Channel 9, started exploring the LINQ features. Surprisingly, few facts...
13
2157
by: Analizer1 | last post by:
Hello all I have a idea...and dont know if it is possible...... we have a pretty huge system at work and we send EDI Special formatted Data to Several Other Companies, via sFtp,dial up, vpn...
7
4324
by: devnew | last post by:
hi i am trying to create a cache of digitized values of around 100 image files in a folder..In my program i would like to know from time to time if a new image has been added or removed from the...
0
7119
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6989
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
7195
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...
1
6873
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5453
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4889
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4579
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1400
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
285
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.