473,320 Members | 2,080 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,320 software developers and data experts.

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.FileName = "cmd.exe";
//p.StartInfo.Arguments = "/C &&exit";

p.StartInfo.Arguments = "/C "+workPath + _pid.ToString() +
".exe <" + probPath + _pid.ToString() + ".in >" + workPath +
_pid.ToString() + ".out &&exit";
p.StartInfo.CreateNoWindow = true;
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.Start();

//while (!p.WaitForExit(_timelimit))
while(!p.HasExited)
{
p.Refresh();
memory = (int)(p.WorkingSet64 >10);
runtime = p.UserProcessorTime.Milliseconds;
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<1000000;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
0 830

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

Similar topics

5
by: Stanley | last post by:
Process p = new Process(); p.StartInfo.FileName = "a.exe"; //........... when it executes, it may be create segment error, and the error will be displyed on the screen. how can I make it...
0
by: Phil Lindsay | last post by:
I am having trouble getting setup.exe (which installs MSDE 2K SP3) to install an instance. It seems to go most of the way and then hang. If I run the setup.exe (standalone) from the command line...
5
by: Mark | last post by:
Hi all, I am trying to execute a batch file to copy over files from one server to another. The batch file is using robocopy to copy over the files. ============ private void CopyFiles() {// Use...
2
by: Tenacious | last post by:
I have been trying to run this program called mysqlbinlog.exe from my main c# application using the Process class(See example below). The way that mysqlbinlog functions is to read the first file in...
0
by: muntyanu | last post by:
Hi All, I got permission issue when accesing network files from the application that was started using Process component. Actually I have my .NET windows service running. From this service I...
3
by: Kathy Burke | last post by:
Hi, I'm trying to open an executable file from intranet asp.net page in ..Net 1.1. The following code fires but hangs after processing for about 45 seconds (no error message, just hangs). Dim p...
1
by: Sreelu | last post by:
Hi One of my applications need to upload some data to some secured sites, using SFTP. This is to be done dynamically. So I'm creating a batch file on the fly and calling a script file(.txt), using...
0
by: emailallrise | last post by:
Hi ya all, I'v made a simple app that reads the *.vbproj file and generates a command line that I can execute on the console to compile my app. Now I modified my app so that by using the process...
3
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...
1
by: Wang E | 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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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...

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.