#ident "$Id$" /* How fast can we read a file usng the cachetable interface. */ #ident "Copyright (c) 2007, 2008 Tokutek Inc. All rights reserved." #include "test.h" #include "includes.h" #include enum { KEYLIMIT = 4, BLOCKSIZE=1<<20, N=2048}; static void f_flush (CACHEFILE f, int UU(fd), CACHEKEY key, void *value, void** UU(dd), void *extra __attribute__((__unused__)), PAIR_ATTR size, PAIR_ATTR* new_size __attribute__((__unused__)), BOOL write_me, BOOL keep_me, BOOL for_checkpoint __attribute__((__unused__)), BOOL UU(is_clone) ) { assert(size.size==BLOCKSIZE); if (write_me) { toku_os_full_pwrite(toku_cachefile_get_and_pin_fd(f), value, BLOCKSIZE, key.b); toku_cachefile_unpin_fd(f); } if (!keep_me) { toku_free(value); } } static int f_fetch (CACHEFILE f, int UU(fd), CACHEKEY key, u_int32_t fullhash __attribute__((__unused__)), void**value, void** UU(dd), PAIR_ATTR *sizep, int *dirtyp, void*extraargs __attribute__((__unused__))) { void *buf = toku_malloc(BLOCKSIZE); int r = pread(toku_cachefile_get_and_pin_fd(f), buf, BLOCKSIZE, key.b); toku_cachefile_unpin_fd(f); assert(r==BLOCKSIZE); *value = buf; *sizep = make_pair_attr(BLOCKSIZE); *dirtyp = 0; return 0; } const char fname[] = __FILE__ ".dat"; CACHETABLE t; CACHEFILE f; static void open_file (void ) { int r; r = toku_create_cachetable(&t, KEYLIMIT, ZERO_LSN, NULL_LOGGER); assert(r==0); r = toku_cachetable_openf(&f, t, fname, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r==0); } static void writeit (void) { struct timeval start, end; gettimeofday(&start, 0); int i, r; for (i=0; i