1 #include <stdio.h> 2 #include <assert.h> 3 #include <string.h> 4 #include <stdlib.h> 5 6 static const char s_testData[] = "1234567890" 7 "1234567890" 8 "1234567890" 9 "1234567890" 10 "1234567890" 11 "1234567890" 12 "1234567890" 13 "1234567890" 14 "1234567890" 15 "1234567890"; 16 17 static const char s_testFmt[] = "1234567890" 18 "1234567890" 19 "1234567890" 20 "1234567890" 21 "1234567890" 22 "1234567890" 23 "1234567890" 24 "1234567890" 25 "1234567890" 26 "1234567890" 27 "%s"; 28 static Test5(unsigned loops)29void Test5 ( unsigned loops ) 30 { 31 assert( strlen( s_testData ) == 100 ); 32 assert( strlen( s_testFmt ) == 102 ); 33 34 // Compile this code with -fno-builtin. 35 36 char buffer[300]; 37 38 for ( unsigned i = 0; i < loops; ++i ) 39 { 40 sprintf( buffer, s_testFmt, s_testData ); 41 } 42 } 43 44 int main(int argc,char ** argv)45main(int argc, char **argv) 46 { 47 unsigned loops = 0; 48 49 if (argc >= 2) 50 loops = atoi(argv[1]); 51 if (loops == 0) 52 loops = 1000; 53 printf("loops: %u\n", loops); 54 Test5(loops); 55 exit(0); 56 } 57