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! 1 1851
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! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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))
|
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...
|
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 =...
|
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....
|
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
| |
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:
|
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();...
|
by: StephQ |
last post by:
I have a class Bounds with two constructors:
class Bounds
{
private:
list<SegmentupperLinearSpline; // Upper bound.
list<SegmentlowerLinearSpline; // Lower bound.
....
|
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...
|
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...
|
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,...
| |
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...
|
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,...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |