473,657 Members | 2,270 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Time ./a.out equivalent in Windows

Is there an equivant method of

'time ./a.out'

in Windows to measure execution time for a program?

Best Regards,
Karthigan.
Mar 16 '08 #1
17 4212
Karthigan Srinivasan wrote:
Is there an equivant method of

'time ./a.out'

in Windows to measure execution time for a program?

Best Regards,
Karthigan.
Download the package available at the following link:

<http://unxutils.source forge.net/>

Mar 16 '08 #2
"Karthigan Srinivasan" <ka*******@eart hlink.netwrites :
Is there an equivant method of

'time ./a.out'

in Windows to measure execution time for a program?
We don't know. Well, some people here might happen to know, but this
isn't the place to ask, since your question really isn't about the C
programming language.

Try one of the comp.os.ms-windows.* or microsoft.* newsgroups.

--
Keith Thompson (The_Other_Keit h) <ks***@mib.or g>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Mar 16 '08 #3
"Karthigan Srinivasan" <ka*******@eart hlink.netwrote in message
news:op.t74o4kv wpinhaa@karthig an-desktop...
Is there an equivant method of

'time ./a.out'

in Windows to measure execution time for a program?
I put together the C program below which vaguely works, but you might get
ideas on how to do it properly. (I've never used command parameters in C
before).

--
Bart

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>

int main(int n,char **cmds)
{char cmdstring[260];
int t;
int i,m;
char **p;

if (n<=1)
{if (n==1) printf("Usage: %s filename\n",*cm ds);
return EXIT_FAILURE;
};

++cmds; /* first param of interest, should be exe name */

/* must check all params combined fit into cmdstring (you can ignore this if
not posting your code!) */
m=0;
p=cmds;
for (i=2; i<=n; ++i) m+=(strlen(*p++ )+1);
if (m>sizeof(cmdst ring)) return EXIT_FAILURE;

/* All the trouble the system went to to separate the params, now we need to
join them all together again with spaces between */
/* Hint: if you can use Winmain() instead, the params are already joined up
*/

strcpy(cmdstrin g,*cmds);
for (i=3; i<=n; ++i)
{strcat(cmdstri ng," ");
strcat(cmdstrin g,*(++cmds));
};

printf("Executi ng %s ...\n",cmdstrin g);

t=clock();

system(cmdstrin g);

t=clock()-t;

printf("Executi on time: %d msec",t);

return EXIT_SUCCESS;
}

Mar 16 '08 #4
Bartc wrote:

<snip>

I think you should divide the difference by CLOCKS_PER_SEC to get the
result in seconds. As such your program's result is always zero. This
is because you are strong a return value of type clock_t into an int.
Use a clock_t variable.

Also you could use malloc for concatenating the command arguments to
deal with large number of/long strings.

Mar 16 '08 #5
Bartc wrote:

<snip>

Since your program is paused by the operating system when the command
given to *system* is executing, both the return values from clock will
be the same, and thus the difference will always be zero.

You need to use functions beyond the C standard like POSIX *times*
function in sys/times.h to do this properly.

Mar 16 '08 #6
On Mar 16, 3:41*pm, "Bartc" <b...@freeuk.co mwrote:
t=clock();

system(cmdstrin g);

t=clock()-t;

printf("Executi on time: %d msec",t);
This output lies to the user if CLOCKS_PER_SEC isn't 1000.
Mar 16 '08 #7

"santosh" <sa*********@gm ail.comwrote in message
news:fr******** **@registered.m otzarella.org.. .
Bartc wrote:

<snip>

Since your program is paused by the operating system when the command
given to *system* is executing, both the return values from clock will
be the same, and thus the difference will always be zero.
That's a good point. clock() should give the execution time of the program
doing the timing.

Nevertheless, it seemed to work! Or at least gave sensible results.

Maybe something to with Windows, and the OP wanted this on Windows.

--
Bart
Mar 16 '08 #8
santosh wrote:

<snip>

Well it is horribly broken in the sense that it will collapse all it's
arguments without preserving a space between them. A quick workaround
is to enclose all the arguments to the program inside a pair of double
quotes. Fixing it is left to the OP. :-)

Mar 17 '08 #9
Bartc wrote:
>
"santosh" <sa*********@gm ail.comwrote in message
news:fr******** **@registered.m otzarella.org.. .
>Bartc wrote:

<snip>

Since your program is paused by the operating system when the command
given to *system* is executing, both the return values from clock
will be the same, and thus the difference will always be zero.

That's a good point. clock() should give the execution time of the
program doing the timing.
It does. Trouble is, the execution of our program is suspended when the
argument to system is running. As far as clock is concerned, no time
has elapsed between the call to system and it's return.

To stick to pure standard C we will have to use the time function, whose
resolution is usually isn't sufficient for use in a "time" command.

<snip>

Mar 17 '08 #10

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

Similar topics

6
8752
by: carbon_dragon | last post by:
Ok, so here is the problem. I'm working on a headless server program implemented as a .NET C# Console project. There is a UPS mounted to this server (though not a windows compliant UPS). I can only talk to the UPS over a special device driver. Through this device driver I can detect that the UPS is going to notify Windows 2000 server to shut down. So I start doing a graceful termination. But Windows shuts down pretty quickly and there...
3
1496
by: leo_junquera | last post by:
I am trying to use windows authentication on an intranet to call a web service. When I make my first call to the service after connecting from a client app using: ws.Url = ServiceUrl; ws.Credentials = System.Net.CredentialCache.DefaultCredentials; ws.UnsafeAuthenticatedConnectionSharing = true; It takes forever (2-3 minutes) and my mem usage for aspnet_wp.exe balloons from 2,952K to 586,264K and stays there.
2
6024
by: anand.ba | last post by:
Hi all I need to find equivalent windows libraries for the following unix ones. #include <sys/prctl.h> #include <sys/ioctl.h> #include <unistd.h>
9
1636
by: aaronluna | last post by:
Hi All, I was wondering if it is possible to easily convert an asp.net user control (.ascx) into an equivalent windows app. I plan on simply duplicating the user control in a c# windows app through brute force, but am becoming pressed for time with multiple deadlines. If there is an easier way than building the entire c# app from scratch, I would greatly appreciate the advice. The form contains listboxes, buttons, labels, textboxes...
4
1998
by: chaitanya.sharma | last post by:
Hi, I am looking for a function that is similar to rl_bind_key (linux) for windows. Is there any such function. I am creating a small shell and want to detect if a particular key is pressed on the shell. Do let me know if theres a solution. Regards, Chaitanya
0
931
by: Will | last post by:
Can anyone recommend how I would build a tag cloud on a Windows Form? Is there a control I can use instead of the web based literal control?
1
1268
by: Pankajmani das | last post by:
I have developed a program which is need to run automatically when windows/computer start. I have kept my exe file in startup and task folder manually and it work also. Please let me know the code for doing all this things, and if another process is there.
0
868
by: mukeshk | last post by:
hi, I want to know the project directory path for my windows application. I have a file(say Myfile.txt) which is included in the project as Solution Dir -Project Dir --project files --Myfile.txt when i run the project the binaries are located in \bin\debug or release folders. but when create a setup and deploy the project the binaries are directly deployed in the project folder, due to which there is two different paths at development &...
0
973
by: vijayat23 | last post by:
In my application, there is a situation, I have to re size the controls during runtime. How can i achieve that. Thanks in advance
8
1845
by: Theo v. Werkhoven | last post by:
hi, In this code I read out an instrument during a user determined period, and save the relative time of the sample (since the start of the test) and the readback value in a csv file. #v+ from datetime import * from time import * from visa import *
0
8411
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8323
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8739
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...
1
8513
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7351
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
6176
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
5638
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1732
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.