#define TEST_READ 1 #define TEST_WRITE 2 char *test_type[] = { "", "read", "write" }; ULONG ulTest = TEST_READ; ULONG ulIter = 5, ulOps = 250, ulSize = 64L*1024L, ulBlock = 4096, ulCtn = 1; int fMove = FALSE; #define MAXBUF 64000L char *buf; #define MAXCTN 64 CTN ctn_stack[MAXCTN]; void usage(void) { printf("%s Version\n", BUILD_TYPE); printf("Usage: readtm [options]\n"); printf("Options are:\n"); printf(" -? This list\n"); printf(" -t # Test number:\n"); printf(" %d - Reads, default\n", TEST_READ); printf(" %d - Writes\n", TEST_WRITE); printf(" -i # Number of averaging iterations (default = %lu)\n", ulIter); printf(" -o # Number of operations per iteration (default = %lu)\n", ulOps); printf(" -z # Number of operations per iteration by size " "(default = %lu)\n", ulOps*ulBlock); printf(" -s # Size of stream (default = %lu)\n", ulSize); printf(" -b # Size of block (default = %lu, max = %ld)\n", ulBlock, MAXBUF); printf(" -c # Number of nested containers (default = %lu)\n", ulCtn); printf(" -w Walk around stream\n"); printf(" -x Allow stream to grow\n"); printf(" -d Use direct mode\n"); exit(1); } void _CRTAPI1 main(int argc, char *argv[]) { CTN ctn; STM stm; ULONG i, j, ulRet, ulPos; ULONG ulDFDebug = 0x101, ulMSDebug = 0x101; int dwTFlags = PM_TRANSACTED; time_t start, duration, sum = 0; int fNew = TRUE; int fGrow = FALSE; for (i = 1; (int)i 0; i--) { commit_ctn(ctn_stack[i-1]); printf("Container %lu committed\n", i); release_ctn(ctn_stack[i-1]); printf("Container %lu released\n", i); } } ctn = NULL; for (i = 0; i ulSize) { seek_stm(stm, 0); ulPos = ulBlock; } } switch(ulTest) { case TEST_READ: if ((ulRet = read_stm(stm, buf, ulBlock)) != ulBlock) { printf("Read %lu bytes instead of %lu\n", ulRet, ulBlock); i = ulOps; } break; case TEST_WRITE: if ((ulRet = write_stm(stm, buf, ulBlock)) != ulBlock) { printf("Wrote %lu bytes instead of %lu\n", ulRet, ulBlock); i = ulOps; } break; } } duration = time(&duration)-start; sum += duration; printf("Iteration %lu of %lu, %lu %ss on %lu bytes:\n\t" "%ld seconds, average %.3lf\n", j+1, ulIter, ulOps, test_type[ulTest], ulBlock, duration, (double)sum/(j+1)); } release_stm(stm); printf("Stream released\n"); for (i = ulCtn; i > 0; i--) { release_ctn(ctn_stack[i-1]); printf("Container %lu released\n", i); } free(buf); }