Compares HTTP request performance across different implementations.
bun script.ts| Implementation | Time (ms) | Protocol |
|---|---|---|
| C native (http DNS) | ~90-150 | HTTP |
| C native OpenSSL (IP) | ~180-200 | HTTPS |
| C curl HTTP/2 | ~170-180 | HTTPS |
| C native OpenSSL (DNS) | ~170-200 | HTTPS |
| C Boost.Asio | ~180-220 | HTTPS |
| C libcurl | ~180-250 | HTTPS |
| C Network.framework | ~170-350 | HTTPS |
| Bun fetch | ~180-300 | HTTPS |
ms
350 ┤ █
300 ┤ █
250 ┤ █ █
200 ┤ █ █ █ █ █
150 ┤ █ █ █ █ █ █
100 ┤ █ █ █ █ █ █
50 ┤ █ █ █ █ █ █
0 ┼────█─────────█───█─────█───█─────█────
C DNS C IP HTTP/2 OpenSSL Boost libcurl Network Bun
script.ts- Main benchmark script (compiles C/C++ and runs tests)c-curl.c- C implementation using libcurl (HTTPS)c-native.c- C implementation using raw sockets with DNS (HTTP)c-native-ip.c- C implementation using raw sockets + OpenSSL with direct IP (HTTPS)c-boost.cpp- C++ implementation using Boost.Asio (HTTPS)c-native-openssl.c- C implementation using raw sockets + OpenSSL with DNS (HTTPS)c-networkfw.c- C implementation using Apple's Network.framework (HTTPS)c-http2.c- C implementation using curl with HTTP/2 (HTTPS)networkfw- Compiled executable for Network.frameworkhttp2- Compiled executable for HTTP/2 benchmark
- Native C with raw sockets is fastest for HTTP
- DNS lookup adds minimal overhead (~2ms)
- OpenSSL with direct IP is faster than with DNS
- HTTP/2 (curl) performs similarly to HTTP/1.1 for single requests
- libcurl and Network.framework perform similarly
- Bun's fetch is competitive with native implementations