#include <time.h> #include <strstrea.h> extern "C" { __declspec(dllexport) int test(int iterations); } __declspec(dllexport) int test(int iterations) { strstream sTest; sTest.width(10); // set the width to 10 // sTest.str() returns a pointer to the internal // char array and "freezes" the array. // sTest.rdbuf->freeze( 0 ) "unfreezes" the array. clock_t tStart = clock(); for ( int i = 0; i < iterations; i++ ) { sTest << i; } return (int) (clock() - tStart); }called by:
#define ITERATIONS 10000 local cstr, lnow, i cstr = '' lnow = seconds() for i = 1 to ITERATIONS cstr = cstr + str(i) endfor ? "Visual Foxpro Time: " + str((seconds() - lNow) * 1000) declare Integer test in e:\test2\Release\test2.dll as test ; Integer Iterations ? "C++ Stream Time: " + str(test(ITERATIONS)) clear allCompared to VFP 5.0a, the C++ takes aprox. half the time. See how VFP 6.0 fairs.