Hacker News new | past | comments | ask | show | jobs | submit login
Timing with Curl (2010) (susam.net)
89 points by kamaraju on Aug 15, 2023 | hide | past | favorite | 13 comments



Oh this is fantastic. I had no idea curl could even do this sort of thing. Every time I think I have my head around everything curl can do, I am proven wrong. It really is an amazing tool that enables so many things.


I had the same reaction upon learning that curl can talk LDAP.


That's really cool. TIL.

Also, curl can talk ftp, upload and download. Which is super useful when dealing with legacy things.


WHAT


If I download the latest version of curl.exe for Windows, I will find that all of these subsystems are enabled:

  C:>curl --version
  curl 8.2.1 (x86_64-w64-mingw32) libcurl/8.2.1 OpenSSL/3.1.2 (Schannel) zlib/1.2.13 brotli/1.0.9 zstd/1.5.5 WinIDN libssh2/1.11.0 nghttp2/1.55.1 ngtcp2/0.18.0 nghttp3/0.14.0 libgsasl/2.2.0
  Release-Date: 2023-07-26
  Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp ws wss
  Features: alt-svc AsynchDNS brotli gsasl HSTS HTTP2 HTTP3 HTTPS-proxy IDN IPv6 Kerberos Largefile libz MultiSSL NTLM SPNEGO SSL SSPI threadsafe UnixSockets zstd
However, Microsoft also distributes its own version of curl.exe, with vastly less capability:

  C:\>cd temp

  C:\Temp>curl --version
  curl 8.0.1 (Windows) libcurl/8.0.1 Schannel WinIDN
  Release-Date: 2023-03-20
  Protocols: dict file ftp ftps http https imap imaps pop3 pop3s smtp smtps telnet tftp
  Features: AsynchDNS HSTS HTTPS-proxy IDN IPv6 Kerberos Largefile NTLM SPNEGO SSL SSPI threadsafe Unicode UnixSockets
I don't know why Microsoft removes all of this functionality. They should not do this.


Very straightforward reason: less capabilities for naughty executables to "live off the land" from.

Kind of like the sysadmins removing any scripting languages and compilers from servers to avoid giving rogue processes any leg up. It's legitimately making it harder for baddies to exploit a way in. ...Though it's never been easier to package your own interpreter (micropython or equivalent), so I don't expect it slows people down much.

In the mindset of MS: legit devs should package their own tooling, and baddies shouldn't get the freebies.


I didn't really think about it from that perspective. It makes sense.


curl is fantastic. There's also HTTPStat which provides a waterfall visualization on top of curl timings: https://github.com/reorx/httpstat

There's also Skytrace (made by yours truly), which provides timing info as a waterfall visualization inspired by HTTPStat + lots more (syntax highlighting for responses, built-in JMESPath support, command-line assertions and checks etc) - https://github.com/artilleryio/artillery/tree/main/packages/...


Nit:

> Here is the same command written as a one-liner

Maybe don't include the "\n" in the triple-click selection so that one can inspect it before hitting enter. Currently it copies the "\n" to the clipboard and then when you paste in the terminal it directly executes.


Did they fix it? Triple clicking and pasting doesn't lead to immediate execution for me.

But even better is to just put such commands in .bashrc as functions. e.g.

    curltime() {
      curl -L -w "time_namelookup: %{time_namelookup}\ntime_connect: %{time_connect}\ntime_appconnect: %{time_appconnect}\ntime_pretransfer: %{time_pretransfer}\ntime_redirect: %{time_redirect}\ntime_starttransfer: %{time_starttransfer}\ntime_total: %{time_total}\n" "$1"
    }


great for doing measurements in a cron to later plot them. Here someone measured TLS version latencies on gov.uk - https://nooshu.com/blog/2020/07/30/measuring-tls-13-ipv4-ipv... and has a good graph explaining the time_* variables


curl is such an amazing tool. Most of my coworkers are not comfortable with the command line and prefer to use GUI tools like postman. Having curl as part of your shell's history is a minor super power.

What was that API end point that was failing 3 months ago with a weird status?

1. Hit C-r for reverse search (bonus if you've got fzf installed) 2. Type a partial URL 3. Identify the curl command you want, and hit enter.

I recently used timing support (as described in the article). I actually found it in AWS docs when I was trying to understand why things weren't as fast as expected. Now it's in permanent record in my shell.

Anyway, +1 for curl.


--trace-time is also great in curl




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: