Last active
June 14, 2023 05:41
-
-
Save SP3269/78ee1b749a80c5421c350fa62fdb1804 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Using curl to measure TLS negotiation time, as a proxy of PKCS #11 performance | |
# https://blog.cloudflare.com/a-question-of-timing/ | |
function Get-ConnectionTimes ([string] $Uri) { | |
$curl = curl -w "%{time_namelookup},%{time_connect},%{time_appconnect}\n" -s -o /dev/null $Uri | |
$namelookup,$connect,$appconnect = $curl -split "," | |
$res = [PSCustomObject]@{ | |
namelookup = [float]$namelookup | |
connect = [float]$connect | |
appconnect = [float]$appconnect | |
} | |
return $res | |
} | |
function Get-TLSHandshakeTime ([string] $Uri) { | |
$res = Get-ConnectionTimes $Uri | |
return $res.appconnect - $res.connect | |
} | |
# Example | |
1..20 | % {Get-ConnectionTimes "https://www.googleapis.com"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment