Commit 9b1ea292 authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul Committed by Yoni Fogel

Merge in [11215], Refs #1672. Consolidate tdiff. Fixes #1673.

git-svn-id: file:///svn/toku/tokudb@11217 c7de825b-a66e-492c-adef-691d508d4ae1
parent 82c65979
......@@ -14,7 +14,6 @@ DEPEND_COMPILE += \
./*.h \
#end
SKIP_NORETURN=1 #Do not add the -Wmissing-noreturn flag
HERE = db-benchmark-test-cxx
include $(TOKUROOT)toku_include/Makefile.include
......
......@@ -15,7 +15,6 @@ DEPEND_COMPILE += \
test.h \
#end
SKIP_NORETURN=1 #Do not add the -Wmissing-noreturn flag
HERE = db-benchmark-test
include $(TOKUROOT)toku_include/Makefile.include
......
......@@ -270,10 +270,6 @@ static void random_insert_below (long long below) {
}
}
static double tdiff (struct timeval *a, struct timeval *b) {
return (a->tv_sec-b->tv_sec)+1e-6*(a->tv_usec-b->tv_usec);
}
static void biginsert (long long n_elements, struct timeval *starttime) {
long long i;
struct timeval t1,t2;
......@@ -283,16 +279,16 @@ static void biginsert (long long n_elements, struct timeval *starttime) {
gettimeofday(&t1,0);
serial_insert_from(i);
gettimeofday(&t2,0);
if (verbose) printf("serial %9.6fs %8.0f/s ", tdiff(&t2, &t1), items_per_iteration/tdiff(&t2, &t1));
if (verbose) printf("serial %9.6fs %8.0f/s ", toku_tdiff(&t2, &t1), items_per_iteration/toku_tdiff(&t2, &t1));
fflush(stdout);
}
if (!norandom) {
gettimeofday(&t1,0);
random_insert_below((i+items_per_iteration)*SERIAL_SPACING);
gettimeofday(&t2,0);
if (verbose) printf("random %9.6fs %8.0f/s ", tdiff(&t2, &t1), items_per_iteration/tdiff(&t2, &t1));
if (verbose) printf("random %9.6fs %8.0f/s ", toku_tdiff(&t2, &t1), items_per_iteration/toku_tdiff(&t2, &t1));
}
if (verbose) printf("cumulative %9.6fs %8.0f/s\n", tdiff(&t2, starttime), (((float)items_per_iteration*(!noserial+!norandom))/tdiff(&t2, starttime))*(iteration+1));
if (verbose) printf("cumulative %9.6fs %8.0f/s\n", toku_tdiff(&t2, starttime), (((float)items_per_iteration*(!noserial+!norandom))/toku_tdiff(&t2, starttime))*(iteration+1));
}
}
......@@ -360,7 +356,7 @@ test1514(void) {
CKERR2(r, DB_NOTFOUND);
r = c->c_close(c); CKERR(r);
if (verbose) printf("(#1514) Single Point Query %9.6fs\n", tdiff(&t2, &t1));
if (verbose) printf("(#1514) Single Point Query %9.6fs\n", toku_tdiff(&t2, &t1));
}
#endif
......@@ -491,9 +487,9 @@ int main (int argc, const char *argv[]) {
benchmark_shutdown();
gettimeofday(&t3,0);
if (verbose) {
printf("Shutdown %9.6fs\n", tdiff(&t3, &t2));
printf("Total time %9.6fs for %lld insertions = %8.0f/s\n", tdiff(&t3, &t1),
(!noserial+!norandom)*total_n_items, (!noserial+!norandom)*total_n_items/tdiff(&t3, &t1));
printf("Shutdown %9.6fs\n", toku_tdiff(&t3, &t2));
printf("Total time %9.6fs for %lld insertions = %8.0f/s\n", toku_tdiff(&t3, &t1),
(!noserial+!norandom)*total_n_items, (!noserial+!norandom)*total_n_items/toku_tdiff(&t3, &t1));
}
#if 0 && defined TOKUDB
if (verbose) {
......
#ifndef TOKU_TIME_H
#define TOKU_TIME_H
#include <time.h>
#include <sys/time.h>
#ifdef __cplusplus
extern "C" {
#endif
static inline float toku_tdiff (struct timeval *a, struct timeval *b) {
return (a->tv_sec - b->tv_sec) +1e-6*(a->tv_usec - b->tv_usec);
}
#ifdef __cplusplus
};
#endif
#endif
......@@ -153,5 +153,4 @@ int maybe_preallocate_in_file (int fd, u_int64_t size);
int toku_brt_note_table_lock (BRT brt, TOKUTXN txn);
// Effect: Record the fact that the BRT has a table lock (and thus no other txn will modify it until this txn completes. As a result, we can limit the amount of information in the rollback data structure.
#endif
......@@ -5,6 +5,7 @@
/* Insert a bunch of stuff */
#include "includes.h"
#include "toku_time.h"
static const char fname[]="sinsert.brt";
......@@ -75,10 +76,6 @@ static void random_insert_below (long long below) {
}
}
static double tdiff (struct timeval *a, struct timeval *b) {
return (a->tv_sec-b->tv_sec)+1e-6*(a->tv_usec-b->tv_usec);
}
static void biginsert (long long n_elements, struct timeval *starttime) {
long long i;
struct timeval t1,t2;
......@@ -89,7 +86,7 @@ static void biginsert (long long n_elements, struct timeval *starttime) {
serial_insert_from(i);
gettimeofday(&t2,0);
if (verbose && do_serial) {
printf("serial %9.6fs %8.0f/s ", tdiff(&t2, &t1), ITEMS_TO_INSERT_PER_ITERATION/tdiff(&t2, &t1));
printf("serial %9.6fs %8.0f/s ", toku_tdiff(&t2, &t1), ITEMS_TO_INSERT_PER_ITERATION/toku_tdiff(&t2, &t1));
fflush(stdout);
}
gettimeofday(&t1,0);
......@@ -97,14 +94,14 @@ static void biginsert (long long n_elements, struct timeval *starttime) {
random_insert_below((i+ITEMS_TO_INSERT_PER_ITERATION)*SERIAL_SPACING);
gettimeofday(&t2,0);
if (verbose && do_random) {
printf("random %9.6fs %8.0f/s ", tdiff(&t2, &t1), ITEMS_TO_INSERT_PER_ITERATION/tdiff(&t2, &t1));
printf("random %9.6fs %8.0f/s ", toku_tdiff(&t2, &t1), ITEMS_TO_INSERT_PER_ITERATION/toku_tdiff(&t2, &t1));
fflush(stdout);
}
if (verbose && (do_serial || do_random)) {
double f = 0;
if (do_serial) f += 1.0;
if (do_random) f += 1.0;
printf("cumulative %9.6fs %8.0f/s\n", tdiff(&t2, starttime), (ITEMS_TO_INSERT_PER_ITERATION*f/tdiff(&t2, starttime))*(iteration+1));
printf("cumulative %9.6fs %8.0f/s\n", toku_tdiff(&t2, starttime), (ITEMS_TO_INSERT_PER_ITERATION*f/toku_tdiff(&t2, starttime))*(iteration+1));
fflush(stdout);
}
}
......@@ -192,8 +189,8 @@ test_main (int argc, const char *argv[]) {
int f = 0;
if (do_serial) f += 1;
if (do_random) f += 1;
printf("Shutdown %9.6fs\n", tdiff(&t3, &t2));
printf("Total time %9.6fs for %lld insertions = %8.0f/s\n", tdiff(&t3, &t1), f*total_n_items, f*total_n_items/tdiff(&t3, &t1));
printf("Shutdown %9.6fs\n", toku_tdiff(&t3, &t2));
printf("Total time %9.6fs for %lld insertions = %8.0f/s\n", toku_tdiff(&t3, &t1), f*total_n_items, f*total_n_items/toku_tdiff(&t3, &t1));
fflush(stdout);
}
if (verbose>1) {
......
......@@ -3,6 +3,7 @@
#include "includes.h"
#include "test.h"
#include "toku_time.h"
static const char fname[]= __FILE__ ".brt";
......@@ -35,8 +36,8 @@ static void test3 (int nodesize, int count, int memcheck) {
toku_memory_check_all_free();
gettimeofday(&t1, 0);
{
double tdiff = (t1.tv_sec-t0.tv_sec)+1e-6*(t1.tv_usec-t0.tv_usec);
if (verbose) printf("serial insertions: blocksize=%d %d insertions in %.3f seconds, %.2f insertions/second\n", nodesize, count, tdiff, count/tdiff);
double diff = toku_tdiff(&t1, &t0);
if (verbose) printf("serial insertions: blocksize=%d %d insertions in %.3f seconds, %.2f insertions/second\n", nodesize, count, diff, count/diff);
}
}
......
......@@ -3,6 +3,7 @@
#include "includes.h"
#include "test.h"
#include "toku_time.h"
static const char fname[]= __FILE__ ".brt";
......@@ -35,8 +36,8 @@ static void test4 (int nodesize, int count, int memcheck) {
toku_memory_check_all_free();
gettimeofday(&t1, 0);
{
double tdiff = (t1.tv_sec-t0.tv_sec)+1e-6*(t1.tv_usec-t0.tv_usec);
if (verbose) printf("random insertions: blocksize=%d %d insertions in %.3f seconds, %.2f insertions/second\n", nodesize, count, tdiff, count/tdiff);
double diff = toku_tdiff(&t1, &t0);
if (verbose) printf("random insertions: blocksize=%d %d insertions in %.3f seconds, %.2f insertions/second\n", nodesize, count, diff, count/diff);
}
}
......
......@@ -4,13 +4,10 @@
#include "test.h"
#include "includes.h"
#include "toku_time.h"
enum { KEYLIMIT = 4, BLOCKSIZE=1<<20, N=2048};
static double tdiff (struct timeval *a, struct timeval *b) {
return (a->tv_sec-b->tv_sec)+1e-6*(a->tv_usec-b->tv_usec);
}
static void f_flush (CACHEFILE f,
CACHEKEY key,
void *value,
......@@ -69,7 +66,7 @@ static void writeit (void) {
r = toku_cachetable_unpin(f, key, fullhash, CACHETABLE_CLEAN, BLOCKSIZE); assert(r==0);
}
gettimeofday(&end, 0);
double diff = tdiff(&end, &start);
double diff = toku_tdiff(&end, &start);
printf("writeit %d blocks of size %d in %6.2fs at %6.2fMB/s\n", N, BLOCKSIZE, diff, (N/diff)*(BLOCKSIZE*1e-6));
}
......@@ -92,9 +89,9 @@ static void readit (void) {
r = toku_cachetable_close(&t); assert(r == 0);
gettimeofday(&end, 0);
toku_os_get_process_times(&end_usertime, &end_systime);
double diff = tdiff(&end, &start);
double udiff = tdiff(&end_usertime, &start_usertime);
double sdiff = tdiff(&end_systime, &start_systime);
double diff = toku_tdiff(&end, &start);
double udiff = toku_tdiff(&end_usertime, &start_usertime);
double sdiff = toku_tdiff(&end_systime, &start_systime);
printf("readit %d blocks of size %d in %6.2fs at %6.2fMB/s user=%6.2fs sys=%6.2fs\n",
N, BLOCKSIZE, diff, (N/diff)*(BLOCKSIZE*1e-6), udiff, sdiff);
}
......
......@@ -46,6 +46,7 @@
toku_stat;
toku_fstat;
toku_tdiff;
local: *;
};
......
......@@ -9,7 +9,6 @@ DEPEND_COMPILE += \
../lock_tree/*.h \
test.h \
#end
SKIP_NORETURN=1 #Do not add the -Wmissing-noreturn flag
include $(TOKUROOT)toku_include/Makefile.include
CPPFLAGS+=-D_GNU_SOURCE
LIBTDB=../libtokudb.$(SOEXT)
......
......@@ -6,6 +6,7 @@
#include <db.h>
#include <toku_pthread.h>
#include <toku_time.h>
#include <sys/stat.h>
#include <unistd.h>
......@@ -90,9 +91,9 @@ static void
printtdiff (char *str) {
struct timeval thistime;
gettimeofday(&thistime, 0);
double tdiff = thistime.tv_sec-prevtime.tv_sec+1e-6*(thistime.tv_usec-prevtime.tv_usec);
double diff = toku_tdiff(&thistime, &prevtime);
int fcount=get_fsync_count();
if (verbose) printf("%s: %10.6fs %d fsyncs for %s\n", progname, tdiff, fcount-prev_count, str);
if (verbose) printf("%s: %10.6fs %d fsyncs for %s\n", progname, diff, fcount-prev_count, str);
prevtime=thistime;
prev_count=fcount;
}
......
......@@ -6,6 +6,7 @@
#include <db.h>
#include <toku_pthread.h>
#include <toku_time.h>
#include <sys/stat.h>
DB_ENV *env;
......@@ -89,7 +90,7 @@ static void
printtdiff (char *str) {
struct timeval thistime;
gettimeofday(&thistime, 0);
if (verbose) printf("%10.6f %s\n", thistime.tv_sec-prevtime.tv_sec+1e-6*(thistime.tv_usec-prevtime.tv_usec), str);
if (verbose) printf("%10.6f %s\n", toku_tdiff(&thistime, &prevtime), str);
}
int
......
......@@ -54,7 +54,7 @@ endif
.DELETE_ON_ERROR:
ifneq ($(GCOV),)
GCOV_FLAGS = -fprofile-arcs -ftest-coverage
GCOV_FLAGS = -fprofile-arcs -ftest-coverage -DGCOV
endif
ifneq ($(PROF),)
......@@ -81,10 +81,7 @@ CPPFLAGS = $(INCLUDEDIRS) -I$(PORTABILITY_HEADERS) -I$(TOKUROOT)toku_include
# Add -Wconversion #DISABLED for now.
WERROR = -Werror
WALL = -Wall -Wextra -Wcast-align -Wbad-function-cast
ifeq ($(SKIP_NORETURN),)
WALL += -Wmissing-noreturn
endif
WALL = -Wall -Wextra -Wcast-align -Wbad-function-cast -Wno-missing-noreturn
FORMAT = -Wmissing-format-attribute
VISIBILITY= -fvisibility=hidden
......@@ -215,7 +212,7 @@ ifneq ($(CYGWIN),)
ifeq ($(WINDBG),1)
VGRIND = windbg -hd -y "$(SRCPATH_DIRS)" -srcpath "$(SRCPATH_DIRS)" #No Valgrind in cygwin #-G is quit at exit, but does not return ERROR on error!!! and quits on error to quickly
else
VGRIND =
VGRIND =
endif
HGRIND =#No Hgrind in cygwin
FPICFLAGS=#FPIC is default and not allowed as an option.
......
......@@ -11,20 +11,15 @@
void toku_do_assert(int,const char*/*expr_as_string*/,const char */*fun*/,const char*/*file*/,int/*line*/);
// Define GCOV if you want to get test-coverage information that ignores the assert statements.
#define GCOV
// #define GCOV
#ifdef GCOV
#undef SLOW_ASSERT
#define WHEN_GCOV(x)
#define WHEN_NOT_GCOV(x) x
#else
#define WHEN_GCOV(x) x
#define WHEN_NOT_GCOV(x)
#endif
#undef assert
#ifdef SLOW_ASSERT
#define assert(expr) toku_do_assert((expr) != 0, #expr, __FUNCTION__, __FILE__, __LINE__)
#else
#define assert(expr) do { if ((expr)==0) toku_do_assert(0, #expr, __FUNCTION__, __FILE__, __LINE__); } while (0)
#define WHEN_GCOV(x)
#define WHEN_NOT_GCOV(x) x
#include <assert.h>
#endif
#endif
......@@ -7,7 +7,6 @@ TOKUROOT=../
INCLUDEDIRS=-I. -I$(TOKUROOT)toku_include -I$(TOKUROOT)include -I$(TOKUROOT)src
DEPEND_COMPILE += \
./*.h \
SKIP_NORETURN=1
#end
HERE = utils
......
......@@ -26,6 +26,10 @@ struct timespec {
int clock_gettime(clockid_t clock_id, struct timespec *ts);
static inline float toku_tdiff (struct timeval *a, struct timeval *b) {
return (a->tv_sec - b->tv_sec) +1e-6*(a->tv_usec - b->tv_usec);
}
#ifdef __cplusplus
};
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment