Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

Newbie Question: Here-Script with PowerShell

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 09-26-2007   #1 (permalink)
Raymund Hemmerling
Guest


 

Newbie Question: Here-Script with PowerShell

Hallo,

I'm new to this newsgroup and I'm new to PowerShell. I've been using a script
under HP-UX to feed a program (laufdaten.exe) with some input wich then
produces a file called md_daten wich then is read by another program
(mdlauf.exe) wich produces some more or less important output. The cpu-
seconds used by mdlauf.exe are measured. Here is the a part of the script:

,------------- [ Unix Here-Script ] -------------
|
| laufdaten.exe << !
| 0
| 0.5
| 3
| 132000
| '''/users/hemmer/mds_neu/TEST/md_erg0.5-7'''
| '''/users/hemmer/mds_neu/TEST/orte0.5-7'''
| '''/users/hemmer/mds_neu/TEST/enrg0.5-7'''
| '''/users/hemmer/mds_neu/TEST/polar0.5-7'''
| !
| time mdlauf2.exe
|
`------------------------------------------------

Is this possible with powershell too? And how can I measure the cpu-time used
by a command with powershell?


Thanx in advance,
Raymund

My System SpecsSystem Spec
Old 09-26-2007   #2 (permalink)
NJC
Guest


 

RE: Newbie Question: Here-Script with PowerShell

Hi,

You can use the following to assess how long a command or script has taken:

Measure-Command {c:\scripts\test.ps1}

"Raymund Hemmerling" wrote:
Quote:

> Hallo,
>
> I'm new to this newsgroup and I'm new to PowerShell. I've been using a script
> under HP-UX to feed a program (laufdaten.exe) with some input wich then
> produces a file called md_daten wich then is read by another program
> (mdlauf.exe) wich produces some more or less important output. The cpu-
> seconds used by mdlauf.exe are measured. Here is the a part of the script:
>
> ,------------- [ Unix Here-Script ] -------------
> |
> | laufdaten.exe << !
> | 0
> | 0.5
> | 3
> | 132000
> | '''/users/hemmer/mds_neu/TEST/md_erg0.5-7'''
> | '''/users/hemmer/mds_neu/TEST/orte0.5-7'''
> | '''/users/hemmer/mds_neu/TEST/enrg0.5-7'''
> | '''/users/hemmer/mds_neu/TEST/polar0.5-7'''
> | !
> | time mdlauf2.exe
> |
> `------------------------------------------------
>
> Is this possible with powershell too? And how can I measure the cpu-time used
> by a command with powershell?
>
>
> Thanx in advance,
> Raymund
>
My System SpecsSystem Spec
Old 09-26-2007   #3 (permalink)
Jacques Barathon [MS]
Guest


 

Re: Newbie Question: Here-Script with PowerShell

"NJC" <NJC@xxxxxx> wrote in message
news:6EB38534-CC20-4465-96F9-B0CF898FDE63@xxxxxx
Quote:

> Hi,
>
> You can use the following to assess how long a command or script has
> taken:
>
> Measure-Command {c:\scripts\test.ps1}
If you want to focus on the total processor time consumed by the process,
you can read the property of the process object. You can do this in several
ways such as:

$myapp = [System.Diagnostics.Process]::Start("<path to my app>\mdlauf.exe")
while (! $myapp.HasExited) {}
$myapp.TotalProcessorTime

Hope that helps,
Jacques

My System SpecsSystem Spec
Old 09-26-2007   #4 (permalink)
Raymund Hemmerling
Guest


 

Re: Newbie Question: Here-Script with PowerShell

NJC schrieb am 26.09.:
Quote:

> You can use the following to assess how long a command or script has taken:
>
> Measure-Command {c:\scripts\test.ps1}
Thanxmuch but I think this gives the real-time a command has taken not the
cpu-time. If there are several commands hunting for cpu-time, the real-time
could be much longer.

Raymund
My System SpecsSystem Spec
Old 09-27-2007   #5 (permalink)
Raymund Hemmerling
Guest


 

Re: Newbie Question: Here-Script with PowerShell

Jacques Barathon [MS] schrieb am 26.09.:
Quote:

> $myapp = [System.Diagnostics.Process]::Start("<path to my app>\mdlauf.exe")
> while (! $myapp.HasExited) {}
> $myapp.TotalProcessorTime
>
> Hope that helps,
Thanxmuch! One Question concerning TotalProcessorTime: does this show on a
multi-cpu-system the sum of all cpu-time used on all cpus by the app?

Raymund
My System SpecsSystem Spec
Old 09-27-2007   #6 (permalink)
Jacques Barathon [MS]
Guest


 

Re: Newbie Question: Here-Script with PowerShell

"Raymund Hemmerling" <just4news@xxxxxx-2007-09-30.arcornews.de> wrote in
message news:Xns99B87B1F8AB24enigma@xxxxxx-63535.user.dfncis.de...
Quote:

> Jacques Barathon [MS] schrieb am 26.09.:
>
Quote:

>> $myapp = [System.Diagnostics.Process]::Start("<path to my
>> app>\mdlauf.exe")
>> while (! $myapp.HasExited) {}
>> $myapp.TotalProcessorTime
>>
>> Hope that helps,
>
> Thanxmuch! One Question concerning TotalProcessorTime: does this show on a
> multi-cpu-system the sum of all cpu-time used on all cpus by the app?
Good question... :-)

I can only assume it does but won't formally say yes. The MSDN documentation
for the property doesn't say anything about it.

Jacques

My System SpecsSystem Spec
Old 09-28-2007   #7 (permalink)
Raymund Hemmerling
Guest


 

Re: Newbie Question: Here-Script with PowerShell

Jacques Barathon [MS] schrieb am 27.09.:
Quote:

> I can only assume it does but won't formally say yes. The MSDN
> documentation for the property doesn't say anything about it.
Yes, this is what I've also read in MSDN docs.

I've tested my app with "Measure-Command" and your solution. And with
TotalProcessorTime I've got 50% more cpu-time than real-time with Measure-
Command on a dual-core system. The app is Fortran- and C-code compiled with
Intel's Compilers using multi-threading-libs.

Raymund
My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Question - flushing out powershell.exe when existing a script Sabo, Eric PowerShell 8 03-26-2008 12:35 PM
Newbie question - Is there a script/command to do a backup of a di dob PowerShell 4 01-03-2008 09:45 AM
Newbie Question - Uses for PowerShell Kim Finleyson PowerShell 11 06-28-2007 07:20 PM
Newbie question: How can I perform web searches from PowerShell? Mark Allen PowerShell 16 05-10-2007 10:41 AM
Newbie question - Powershell/Authentication/IP address =?Utf-8?B?Ym1lcnJpMTk=?= PowerShell 3 07-20-2006 02:38 AM


Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51