Re: strange thing using Process class to call outside executable file



Hi Wang,

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

"Performance Counters"
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/gngrfperformancecounters.asp

--
Dave Sexton

"Wang E" <wange.nuaa@xxxxxxxxx> wrote in message
news:1163739644.434365.187060@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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!



.



Relevant Pages

  • strange thing using Process class to call outside executable file
    ... I've been working on an online judge(for ACM/ICPC) using C#.Programmes ... use the Process class in C#,and my thread is as follows:start a process ... int main ... it comes out that this programme uses around 1800KB memory(this may be ...
    (microsoft.public.dotnet.framework.aspnet)
  • strange thing using Process class to call outside executable file
    ... I've been working on an online judge(for ACM/ICPC) using C#.Programmes ... use the Process class in C#,and my thread is as follows:start a process ... int main ... it comes out that this programme uses around 1800KB memory(this may be ...
    (microsoft.public.dotnet.general)
  • strange thing using Process class to call outside executable file
    ... I've been working on an online judge(for ACM/ICPC) using C#.Programmes ... use the Process class in C#,and my thread is as follows:start a process ... int main ... it comes out that this programme uses around 1800KB memory(this may be ...
    (microsoft.public.dotnet.academic)
  • strange thing using Process class to call outside executable file
    ... I've been working on an online judge(for ACM/ICPC) using C#.Programmes ... use the Process class in C#,and my thread is as follows:start a process ... int main ... it comes out that this programme uses around 1800KB memory(this may be ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: how to count rows and columns of integers/doubles in a file?
    ... the reading and the writing programme are in the same locale, ... unsigned rows, cols, oldcols; ... int countColsInNextLine ... warning C4013: 'system' undefined; assuming extern returning int ...
    (comp.lang.c)

Loading