Performance tests
This directory contains small stand-alone libcurl-using programs that each test specific aspects of the library's performance.
The idea is to have a set of tests here that can be used to verify various libcurl functions' performance when we have no other good means of doing so. Performance is best tested relatively. Does it run slower or faster than before?
Ideally these tests run without using any servers.
base64enc
This test base64 encodes a 256-byte buffer that has every different byte octet represented. Repeatedly in a loop the provided number of times:
./perf base64enc [loops]base64dec
This test base64 decodes a big encoded string. Repeatedly in a loop the provided number of times:
./perf base64dec [loops]dateparser
Runs through 180+ date strings and parses them (converts them to epoch time) loops number of times:
./perf dateparser [loops]maprintf
This test repeatedly formats a request header block with curl_maprintf(), which allocates the result, and measures the time per call. It exercises the allocating output path and a curl_off_t conversion, which the snprintf test does not:
./perf maprintf [loops]numparser
This test repeatedly converts over a hundred different numbers from a string to binary. Decimal, hexadecimal and octal numbers, each with a set cap. Many numbers hit the cap, some numbers are not syntactically correct.
./perf numparser [loops]respheaders
This test runs HTTP/1.1 transfers that each receive a canned response over a local socket pair, with no server involved. It reuses the connection and times three responses: a small one, one with the 26 headers a large web site typically sends and one with 200 headers. It exercises the response header parsing and storing:
./perf respheaders [loops]simpleformat
This test repeatedly formats a commonly used simple message with curl_msnprintf(): literal text plus %s, a size_t and a curl_off_t, with no width or precision. Where snprintf measures an elaborate format, this measures the common one:
./perf simpleformat [loops]snprintf
This test repeatedly formats a representative string and measures the time per call:
./perf snprintf [loops]urlencode
This test URL (percent) encodes a 256-byte buffer that has every different byte octet represented. Repeatedly in a loop the provided number of times:
./perf urlencode [loops]urldecode
This test URL (percent) decodes a 600+ byte buffer. Repeatedly in a loop the provided number of times:
./perf urldecode [loops]urlparser
Provide this test with a list of many URLs and it times how fast it can parse them: ./perf urlparser URLs.txt [loops]
A test sample of 100K URLs can be found here
wsrecv
This test upgrades a connection to WebSocket over a local socket pair, with no server involved, and receives unmasked binary frames of 16, 125, 1024 and 16384 bytes, the last ones loops / 16 times. Like an application, the write callback calls curl_ws_meta() for each frame to learn its type. It exercises the frame decoding and the delivery of each frame to the application:
./perf wsrecv [loops]wssend
This test upgrades a connection to WebSocket over a local socket pair, with no server involved, and sends binary frames with curl_ws_send(). It times frames with 16, 125 and 1024 bytes of payload, and one sixteenth as many with 16384 bytes. The other end of the socket pair only reads and drops the data:
./perf wssend [loops]