Question: My machine is Win7 64 bit. I use PowerShell.

While running gcc or gfortran on my PowerShell I would like to see a 'stopper' (time elapsed) during my program is execute. How can I do that in PowerShell?

I would like that this stop-watch (time elapse) will be on the shell and not part of my code that i am running. 

Is there any command? Do someone give me a script that do it (I am novice).

Answer: 
If you want the time to be constantly displayed while the script(block) is running, you can do something like below:

```
function timer($script, $interval = 1){
    $t = [system.diagnostics.stopwatch]::startnew()
    $job = start-job -script $script
    while($job.state -eq "running"){
        write-host -fore yellow "Elapsed: $($t.elapsed) "
        $job | Receive-Job
        sleep $interval
    }
    $t.stop()
}

timer -script {1..10 | %{ write-host $_ test; start-sleep 2}}

```
Sounds like you want to time a process. Replace $executable and $argument with your specifics. The $timeSpan variable will give you the time it took to complete.

```
$executable = "C:\Windows\notepad.exe"
$arguments = "C:\Windows\WindowsUpdate.log"

$timeSpan = Measure-Command { Start-Process -FilePath $executable -ArgumentList $arguments -Wait -NoNewWindow }

$timeSpan

```

Output:

```
Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 24
Milliseconds      : 255
Ticks             : 242559320
TotalDays         : 0.000280739953703704
TotalHours        : 0.00673775888888889
TotalMinutes      : 0.404265533333333
TotalSeconds      : 24.255932
TotalMilliseconds : 24255.932

```