Created
December 5, 2022 09:19
-
-
Save bagder/959b087c933465317407b20bc0fb0b53 to your computer and use it in GitHub Desktop.
base64 decode performance test
This file contains 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
#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