PowerShell Check the site response and calculate the execution time example _powershell

Source: Internet
Author: User

Sometimes you need to know the execution time of the command, for example, you can use Invoke-webreques to view the response of a Web site, and then use Measure-command to calculate the time of execution.

Copy Code code as follows:

$url = ' http://www.powershell.com '


# Track Execution Time:
$timeTaken = measure-command-expression {
$site = Invoke-webrequest-uri $url
}

$milliseconds = $timeTaken. TotalMilliseconds

$milliseconds = [Math]::round ($milliseconds, 1)

"This took $milliseconds ms to execute"

A "TotalMilliseconds" attribute is included in the Interval property returned, and if you have to, you can use the round () function to make it whole, and in this case we will keep the first digit after the decimal point.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.