473,698 Members | 2,360 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

strange thing using Process class to call outside executable file

I've been working on an online judge(for ACM/ICPC) using C#.Programmes
submitted by users can now be compiled,and it's the problem to judge.I
use the Process class in C#,and my thread is as follows:start a process
using this class with parameters such as input file,output file,etc,and
when the programme is running,i get its running information such as
running time,used memory,etc.I code as follows:
Process p = new Process();
p.StartInfo.Fil eName = "cmd.exe";
//p.StartInfo.Arg uments = "/C &&exit";

p.StartInfo.Arg uments = "/C "+workPath + _pid.ToString() +
".exe <" + probPath + _pid.ToString() + ".in >" + workPath +
_pid.ToString() + ".out &&exit";
p.StartInfo.Cre ateNoWindow = true;
p.StartInfo.Win dowStyle = ProcessWindowSt yle.Hidden;
p.Start();

//while (!p.WaitForExit (_timelimit))
while(!p.HasExi ted)
{
p.Refresh();
memory = (int)(p.Working Set64 >10);
runtime = p.UserProcessor Time.Millisecon ds;
Thread.Sleep(15 );
}
hopefully to get info of programme,it really does!but the result is
just strange.for instance,i write the following C file:
#include <stdio.h>
int main()
{
int i,j;
for(i=0;i<10000 00;i++)
for(j=0;j<100;j ++);
return 0;
}

it comes out that this programme uses around 1800KB memory(this may be
normal),but 0ms time----this is almost impossible! I test it alone,it
run at least 400ms!
there's another weird example:
int main()
{
int i,j;
scanf("%d%d",&i ,&j);
printf("%d",i+j );
return 0;
}

this simple programme should use as much as 1600KB memory!!!

Is there anyone who can tell me what's the problem with my
programme?Or any better way to get used memory and running time of a
programme? Appriciate your help!

Nov 17 '06 #1
1 1848
Hi Wang,

Check out Performance Counters. Specifically, the "Process" category.

"Performanc e Counters"
http://msdn.microsoft.com/library/de...cecounters.asp

--
Dave Sexton

"Wang E" <wa********@gma il.comwrote in message
news:11******** **************@ m7g2000cwm.goog legroups.com...
I've been working on an online judge(for ACM/ICPC) using C#.Programmes
submitted by users can now be compiled,and it's the problem to judge.I
use the Process class in C#,and my thread is as follows:start a process
using this class with parameters such as input file,output file,etc,and
when the programme is running,i get its running information such as
running time,used memory,etc.I code as follows:
Process p = new Process();
p.StartInfo.Fil eName = "cmd.exe";
//p.StartInfo.Arg uments = "/C &&exit";

p.StartInfo.Arg uments = "/C "+workPath + _pid.ToString() +
".exe <" + probPath + _pid.ToString() + ".in >" + workPath +
_pid.ToString() + ".out &&exit";
p.StartInfo.Cre ateNoWindow = true;
p.StartInfo.Win dowStyle = ProcessWindowSt yle.Hidden;
p.Start();

//while (!p.WaitForExit (_timelimit))
while(!p.HasExi ted)
{
p.Refresh();
memory = (int)(p.Working Set64 >10);
runtime = p.UserProcessor Time.Millisecon ds;
Thread.Sleep(15 );
}
hopefully to get info of programme,it really does!but the result is
just strange.for instance,i write the following C file:
#include <stdio.h>
int main()
{
int i,j;
for(i=0;i<10000 00;i++)
for(j=0;j<100;j ++);
return 0;
}

it comes out that this programme uses around 1800KB memory(this may be
normal),but 0ms time----this is almost impossible! I test it alone,it
run at least 400ms!
there's another weird example:
int main()
{
int i,j;
scanf("%d%d",&i ,&j);
printf("%d",i+j );
return 0;
}

this simple programme should use as much as 1600KB memory!!!

Is there anyone who can tell me what's the problem with my
programme?Or any better way to get used memory and running time of a
programme? Appriciate your help!

Nov 17 '06 #2

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

Similar topics

4
3363
by: Jane Austine | last post by:
Running Python 2.3 on Win XP It seems like socket is working interdependently with subprocesses of the process which created socket. ------------------------------------ #the server side >>> import socket >>> s=socket.socket(socket.AF_INET,socket.SOCK_STREAM) >>> s.bind(('localhost',9000))
6
2930
by: Edd Dawson | last post by:
Hi. I have a strange problem involving the passing of command line arguments to a C program I'm writing. I tried posting this in comp.programming yesterday but someone kindly suggested that I'd have better luck here. So here goes! My program ignores any command line arguments, or at least it's supposed to. However, when I pass any command line arguments to the program, the behaviour of one of the functions changes mysteriously. I have...
6
1227
by: WSobczuk | last post by:
I have encountered a very strange error and I'm hoping that some Python hackers here could give me insight on this. searchview.py file contains two functions: def mysearch(indexname, request, c, page = 0, searchdburl = INDEX_URL, query_add = {}, queries = , form = True, limit = DEFAULT_LIMIT, tags = {}, order = ''): and def search(findquery, path = None, page=0, tags = {}, order='', limit = DEFAULT_LIMIT, queries=, searchdburl =...
6
1793
by: Robin Riley | last post by:
Hi, I have a .NET solution that contains a dll project and a tester application project which, of course, invokes the dll. The dll project has exception handling in it. What's happening is that when I run the executable from within the .NET studio environment, thrown exceptions are caught and handled correctly (both debug and release mode). However, if I run the executable from outside the .NET studio, none of the exceptions get caught....
3
1758
by: Vicky_r | last post by:
hi.. I am using Process class to run a .bat file. The .bat file contains the code to run the Session StateServer. First I have written a command in a text file then I convert it to bat and with the help of Process I run the bat file. Now when I use this line "cd C:\WINNT\Microsoft.NET\Framework\v2.0.50727 net start aspnet_state" its
11
2485
by: Mike C# | last post by:
Hi all, I keep getting a strange error and can't pin it down. The message is: This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. However I'm not purposely requesting that the Runtime terminate in an "unusual way." The line that is causing me headaches is:
0
848
by: WangE | last post by:
I've been working on an online judge(for ACM/ICPC) using C#.Programmes submitted by users can now be compiled,and it's the problem to judge.I use the Process class in C#,and my thread is as follows:start a process using this class with parameters such as input file,output file,etc,and when the programme is running,i get its running information such as running time,used memory,etc.I code as follows: Process p = new Process();...
12
2264
by: StephQ | last post by:
I have a class Bounds with two constructors: class Bounds { private: list<SegmentupperLinearSpline; // Upper bound. list<SegmentlowerLinearSpline; // Lower bound. ....
3
1649
by: =?Utf-8?B?UnVkeQ==?= | last post by:
Hello All! I may have posted this problem before, but it was awhile ago. I'm working in VS 2003. I have 10 file watch process going. It seems that I can only about 6or 7 to run at the same time. I made a test program to isolate the problem from my program. Still same thing Basicly I have one application creating a file, the other application running the file watch procces. When a file with a certain extension is created, then a form...
0
8678
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
8609
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
8871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7737
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
6525
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
4371
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
4621
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2333
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
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.