Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@bagder
Created December 5, 2022 09:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bagder/959b087c933465317407b20bc0fb0b53 to your computer and use it in GitHub Desktop.
Save bagder/959b087c933465317407b20bc0fb0b53 to your computer and use it in GitHub Desktop.
base64 decode performance test
#include <stdio.h>
#include <string.h>
#include <curl/curl.h>
#define F "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\x01\xff"
#define F2 F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F
int main(void)
{
printf("%s\n", curl_version());
CURL *curl;
CURLcode res;
curl_global_init(CURL_GLOBAL_DEFAULT);
curl = curl_easy_init();
if(curl) {
size_t max = strlen(F2);
char *base;
size_t baselen;
size_t i;
size_t loops = 1000;
Curl_base64_encode(F2, max, &base, &baselen);
printf("Encoded length: %zu, loops = %d\n", baselen, loops);
for(; loops; loops--) {
for(i = 1; i < baselen; i++ ) {
char *out;
size_t outlen;
Curl_base64_decode(base, &out, &outlen);
curl_free(out);
}
}
curl_easy_cleanup(curl);
}
curl_global_cleanup();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment