473,837 Members | 1,477 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

speed of execution

Hello friends,

Could any one tell the way of calculating the speed of c program
execution?

May 19 '06 #1
40 2997
kavi wrote:
Hello friends,

Could any one tell the way of calculating the speed of c program
execution?

Time it?

--
Ian Collins.
May 19 '06 #2
Ian Collins said:
kavi wrote:
Hello friends,

Could any one tell the way of calculating the speed of c program
execution?

Time it?


That only tells you the time of execution. To calculate the speed, you will
also need to know the distance the program travels within that time.

--
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)
May 19 '06 #3
yes. Exactly.

May 19 '06 #4
Richard Heathfield wrote:
Ian Collins said:
kavi wrote:
Hello friends,

Could any one tell the way of calculating the speed of c program
execution?

Time it?


That only tells you the time of execution. To calculate the speed, you will
also need to know the distance the program travels within that time.


Unless the app is so fast that it distorts space time . Once the speed
of light itself is approached however, buffer overruns cannot occur.
Running the app at a high temperature has also been shown to increase
performance in some cases.

regards
Andy Little

May 19 '06 #5

"Richard Heathfield" <in*****@invali d.invalid> wrote in message
news:nv******** *************** *******@bt.com. ..
Ian Collins said:
kavi wrote:
Hello friends,

Could any one tell the way of calculating the speed of c program
execution?
Time it?


That only tells you the time of execution. To calculate the speed, you

will also need to know the distance the program travels within that time.

Is that why mainframes are faster then? As they are physically bigger the
program bytes have further to travel from the RAM to the CPU so they must
travel at a higher speed?

--
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)

May 19 '06 #6
In article <7_************ ********@eclips e.net.uk>, David Wade
<g8***@yahoo.co m> writes

"Richard Heathfield" <in*****@invali d.invalid> wrote in message
news:nv******* *************** ********@bt.com ...
Ian Collins said:
> kavi wrote:
>> Hello friends,
>>
>> Could any one tell the way of calculating the speed of c program
>> execution?
>>
> Time it?


That only tells you the time of execution. To calculate the speed, you

will
also need to know the distance the program travels within that time.


Is that why mainframes are faster then? As they are physically bigger the
program bytes have further to travel from the RAM to the CPU so they must
travel at a higher speed?


Silly boy..... Lap tops programs are fastest because they travel at
several 100's MPH when used in an aircraft.

Though you could argue programs in satellites are faster (assuming they
are not geo-stationary) but then you have to take relativity into
account......

Is it Friday afternoon again? That came round quickly :-)
--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
/\/\/ ch***@phaedsys. org www.phaedsys.org \/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

May 19 '06 #7
>
Is it Friday afternoon again? That came round quickly :-)

I guess so. But I suppose any one who asks a question like that without
doing an research deserves evrey thing they get,,,

--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
/\/\/ ch***@phaedsys. org www.phaedsys.org \/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

May 19 '06 #8
kavi wrote:

Hello friends,

Could any one tell the way of calculating the speed of c program
execution?


The clock function in <time.h> is for timing programs
or parts of programs.

{
clock_t start, stop;

start = clock();
while (start == clock()) {
;
}
start = clock();
/*
** Timed event goes here
*/
stop = clock();
return (double)(stop - start) / (double)CLOCKS_ PER_SEC;
}

7.23.2.1 The clock function
Synopsis
[#1]
#include <time.h>
clock_t clock(void);
Description
[#2] The clock function determines the processor time used.
Returns
[#3] The clock function returns the implementation' s best
approximation to the processor time used by the program
since the beginning of an implementation-defined era related
only to the program invocation. To determine the time in
seconds, the value returned by the clock function should be
divided by the value of the macro CLOCKS_PER_SEC. If the
processor time used is not available or its value cannot be
represented, the function returns the value clock_t)-1.252)
_______________ _____
252In order to measure the time spent in a program, the
clock function should be called at the start of the
program and its return value subtracted from the value
returned by subsequent calls.

--
pete
May 19 '06 #9
pete said:
kavi wrote:

Hello friends,

Could any one tell the way of calculating the speed of c program
execution?


The clock function in <time.h> is for timing programs
or parts of programs.

{
clock_t start, stop;

start = clock();
while (start == clock()) {
;
}
start = clock();
/*
** Timed event goes here
*/
stop = clock();
return (double)(stop - start) / (double)CLOCKS_ PER_SEC;


This code could, of course, return a /negative/ value, which would make the
performance stats seem very impressive indeed.

--
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)
May 19 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
23084
by: Yang Li Ke | last post by:
Hi guys, Is it possible to know the internet speed of the visitors with php? Thanx -- Yang
4
1585
by: EP | last post by:
On questions of the suitability of Python for CGI, embedded apps, etc., execution speed comes to mind. I previously read some comparisons which did not show Python in a good light in this regard: i.e. Python is slow compared to Perl, C++, Java. http://www.flat222.org/mac/bench/ Is there more authoritative and current information IRT speed comparisons? Is newer Python any faster?
28
2619
by: Maboroshi | last post by:
Hi I am fairly new to programming but not as such that I am a total beginner From what I understand C and C++ are faster languages than Python. Is this because of Pythons ability to operate on almost any operating system? Or is there many other reasons why? I understand there is ansi/iso C and C++ and that ANSI/ISO Code will work on any system If this is the reason why, than why don't developers create specific Python Distrubutions...
40
3067
by: Steve Juranich | last post by:
I know that this topic has the potential for blowing up in my face, but I can't help asking. I've been using Python since 1.5.1, so I'm not what you'd call a "n00b". I dutifully evangelize on the goodness of Python whenever I talk with fellow developers, but I always hit a snag when it comes to discussing the finer points of the execution model (specifically, exceptions). Without fail, when I start talking with some of the "old-timers"...
3
1415
by: linvin333 | last post by:
Hi, Does function overloading affect the speed of execution of the program ? If so what is the reason ? How does it compare with a speed of a program using non-overloded functions ? Linny
9
1679
by: nicolas.hilaire | last post by:
Hi all, i need to choose a langage for porting my vb application to dot net 2.0 in november. For some components, low-level components, i want to know if it can be better to use specific .net language. Basicaly, i want to know if - managed c++ execution is faster than C# execution
4
2084
by: Il Prof | last post by:
Hi to everyone! ;) In C language on Linux, what string access method is faster? 1) Puntatori char str="hello"; char* pstr; pstr = str; // access such as "*pstr"
12
1336
by: Marty | last post by:
Hi, I am building an application that need high speed of execution. There is a lot of string parsing that I do in VB.NET. Do I gain in speed if all that string parsing is made in a dll coded in C or C++ and added to my VB.NET application? I would also gain the advantage of portability, but my main concern is speed of execution.
3
1572
by: serge | last post by:
How do I determine which method I should use if I want to optimize the performance of a database. I took Northwind's database to run my example. My query is I want to retrieve the Employees' First and Last Names that sold between $100,000 and $200,000. First let me create a function that takes the EmployeeID
0
10871
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10564
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9396
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7806
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5668
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5846
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4474
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 we have to send another system
2
4039
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3123
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.