#include xstr.h
#include <string>
int NUM_ITERS=100000;
int test01() {
clock_t t0 = clock();
for (int i=1;i<NUM_ITERS;++i) {
STRINGCLASS str1(Now this is a test...);
STRINGCLASS str2(Now this is a test...);
STRINGCLASS str3(Now this is a test...);
...etc...
STRINGCLASS str10(Now this is a test...);
}
clock_t t1 = clock();
cout << Construction time: << t1 - t0 << / <<
CLOCKS_PER_SEC << secs for << NUM_ITERS <<
iterations << endl;
}
#define Str(x) #x
#define Xstr(x) Str(x)
int main(int argc, char *argv[]) {
if (argc>=2) NUM_ITERS = atol(argv[1]);
cout << test_time; STRINGCLASS = << Xstr(STRINGCLASS) <<
, FLAGS = << Xstr(FLAGS) << endl;
test01();
}
End of Listing