Skip to content

Instantly share code, notes, and snippets.

@bagder
Created October 10, 2017 21:16
Show Gist options
  • Save bagder/ae5c1ec74560f2f4590401befdc5b490 to your computer and use it in GitHub Desktop.
Save bagder/ae5c1ec74560f2f4590401befdc5b490 to your computer and use it in GitHub Desktop.
Test program for comparing sprintf() implementations
#include <stdio.h>
#include <string.h>
#include <curl/curl.h>
#include <curl/mprintf.h>
#define RUNS 10000000
/*#define curl_msnprintf snprintf*/
int main(int argc, char **argv)
{
int i;
char buffer[256];
const char *string1 = "this is the first string";
const char *string2 = "but what about this then?";
for(i=0; i<RUNS; i++) {
curl_msnprintf(buffer, sizeof(buffer),
"%s %3d %4s %-3d %c and some text on that\n",
string1,
2017,
string2,
192,
'#');
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment