Please feel free to provide feedback or file bugs here.

Test-Connection Performance With IP and Output

Votes from Connect: 3

Original Date Submitted: 7/23/2015 12:20:40 AM

Description:
********Contact Information********
Handle: John.Bevan
Site Name: PowerShell
Feedback ID: 1578010
***************************************

Frequency: PowerShell ISE
Regression: Run the below code / view the timings


$ip = '172.24.72.24' #amend for your environment
$hostname = [system.net.dns]::GetHostByAddress($ip).HostName

$begin=(get-date).ticks;test-connection $ip; $a=((get-date).ticks - $begin)
$begin=(get-date).ticks;test-connection $hostname; $b=((get-date).ticks - $begin)
$a-$b

#prove it's not caching; we can do this either way around
$begin=(get-date).ticks;test-connection $hostname; $b=((get-date).ticks - $begin)
$begin=(get-date).ticks;test-connection $ip; $a=((get-date).ticks - $begin)
$a-$b

#now let's see what measure-command says
(measure-command {test-connection $hostname}).ticks
(measure-command {test-connection $ip}).ticks
#that's not what we saw

NB: watching this you can see that the test-connection by IP is slow on each ping; not just on the first one.

Problem Description:
Running `Test-Connection` with an IP address, where the output is displayed performs significantly slower than `Test-Connection` does when passed a hostname (all else being equal).

However if output is not displayed (e.g. when using `Measure-Command` which hides the output from the pipeline, or when using the -`Quiet` parameter, `Test-Connection` is fractionally faster with an IP address than with HostName (as would be expected).

Product Studio item created by Connect Synchronizer due to creation of feedback ID 1578010 (http://connect.microsoft.com/PowerShell/feedback/ViewFeedback.aspx?FeedbackID=1578010).

Repro Steps:
Run the below code / view the timings


$ip = '172.24.72.24' #amend for your environment
$hostname = [system.net.dns]::GetHostByAddress($ip).HostName

$begin=(get-date).ticks;test-connection $ip; $a=((get-date).ticks - $begin)
$begin=(get-date).ticks;test-connection $hostname; $b=((get-date).ticks - $begin)
$a-$b

#prove it's not caching; we can do this either way around
$begin=(get-date).ticks;test-connection $hostname; $b=((get-date).ticks - $begin)
$begin=(get-date).ticks;test-connection $ip; $a=((get-date).ticks - $begin)
$a-$b

#now let's see what measure-command says
(measure-command {test-connection $hostname}).ticks
(measure-command {test-connection $ip}).ticks
#that's not what we saw

NB: watching this you can see that the test-connection by IP is slow on each ping; not just on the first one.

Expected Results:
Test-Connection performance should be negligibly faster when given an IP than when given a DNS name (all else being the same).
Instead it's an order of magnitude slower (when output is passed back to the host).

Internal BugId: 15673

1 vote
Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)

We’ll send you updates on this idea

AdminJoey Aiello [MSFT] (Program Manager, Windows Server) shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

0 comments

Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)
Submitting...

Feedback and Knowledge Base