Permalink
Browse files

Added a small benchmarking utility and fixed some bugs.

  • Loading branch information...
1 parent 791ec87 commit ca54a857e6bbcaed674fadd9fa9291580d89053a Nick committed Feb 17, 2010
Showing with 239 additions and 47 deletions.
  1. +29 −29 autom4te.cache/requests
  2. +4 −1 src/Makefile.am
  3. +29 −3 src/Makefile.in
  4. +5 −9 src/barbershop.c
  5. +160 −0 src/benchmark.c
  6. +12 −5 src/scores.c
View
@@ -75,11 +75,11 @@
'_AM_AUTOCONF_VERSION' => 1,
'AM_DISABLE_SHARED' => 1,
'_LTDL_SETUP' => 1,
- 'AM_PROG_LIBTOOL' => 1,
'_LT_AC_LANG_CXX' => 1,
- 'AM_PROG_LD' => 1,
- '_LT_AC_FILE_LTDLL_C' => 1,
+ 'AM_PROG_LIBTOOL' => 1,
'AC_LIB_LTDL' => 1,
+ '_LT_AC_FILE_LTDLL_C' => 1,
+ 'AM_PROG_LD' => 1,
'AU_DEFUN' => 1,
'AC_PROG_NM' => 1,
'AC_LIBTOOL_DLOPEN' => 1,
@@ -103,29 +103,29 @@
'AC_LTDL_OBJDIR' => 1,
'_LT_PATH_TOOL_PREFIX' => 1,
'AC_LIBTOOL_RC' => 1,
- '_LT_AC_PROG_ECHO_BACKSLASH' => 1,
'AC_DISABLE_FAST_INSTALL' => 1,
- 'include' => 1,
- '_LT_AC_TRY_DLOPEN_SELF' => 1,
+ '_LT_AC_PROG_ECHO_BACKSLASH' => 1,
'_LT_AC_SYS_LIBPATH_AIX' => 1,
+ '_LT_AC_TRY_DLOPEN_SELF' => 1,
+ 'include' => 1,
'LT_AC_PROG_SED' => 1,
'AM_ENABLE_SHARED' => 1,
'LTDL_INSTALLABLE' => 1,
'_LT_AC_LANG_GCJ_CONFIG' => 1,
'AC_ENABLE_SHARED' => 1,
- 'AC_LIBTOOL_SYS_HARD_LINK_LOCKS' => 1,
'AC_ENABLE_STATIC' => 1,
+ 'AC_LIBTOOL_SYS_HARD_LINK_LOCKS' => 1,
'_LT_AC_TAGVAR' => 1,
'AC_LIBTOOL_LANG_F77_CONFIG' => 1,
'AM_CONDITIONAL' => 1,
'LT_LIB_DLLOAD' => 1,
- 'LTVERSION_VERSION' => 1,
'LTDL_INIT' => 1,
- 'm4_include' => 1,
+ 'LTVERSION_VERSION' => 1,
'AM_PROG_INSTALL_SH' => 1,
+ 'm4_include' => 1,
'AC_PROG_EGREP' => 1,
- 'AC_PATH_MAGIC' => 1,
'_AC_AM_CONFIG_HEADER_HOOK' => 1,
+ 'AC_PATH_MAGIC' => 1,
'AC_LTDL_SYSSEARCHPATH' => 1,
'AM_MAKE_INCLUDE' => 1,
'LT_CMD_MAX_LEN' => 1,
@@ -170,40 +170,40 @@
'AM_PROG_NM' => 1,
'AC_LIBLTDL_CONVENIENCE' => 1,
'AC_DEPLIBS_CHECK_METHOD' => 1,
- 'AC_LIBLTDL_INSTALLABLE' => 1,
'AM_SET_CURRENT_AUTOMAKE_VERSION' => 1,
+ 'AC_LIBLTDL_INSTALLABLE' => 1,
'AC_LTDL_ENABLE_INSTALL' => 1,
- 'LT_PROG_GCJ' => 1,
'AC_LIBTOOL_SYS_DYNAMIC_LINKER' => 1,
+ 'LT_PROG_GCJ' => 1,
'AM_INIT_AUTOMAKE' => 1,
'AC_DISABLE_STATIC' => 1,
'LT_PATH_NM' => 1,
'AC_LTDL_SHLIBEXT' => 1,
'_LT_AC_LOCK' => 1,
'_LT_AC_LANG_RC_CONFIG' => 1,
'LT_SYS_MODULE_PATH' => 1,
- 'LT_WITH_LTDL' => 1,
'AC_LIBTOOL_POSTDEP_PREDEP' => 1,
+ 'LT_WITH_LTDL' => 1,
'AC_LTDL_SHLIBPATH' => 1,
'AM_AUX_DIR_EXPAND' => 1,
- 'AC_LIBTOOL_PROG_COMPILER_NO_RTTI' => 1,
'_LT_AC_LANG_F77_CONFIG' => 1,
- '_LT_COMPILER_OPTION' => 1,
+ 'AC_LIBTOOL_PROG_COMPILER_NO_RTTI' => 1,
'_AM_SET_OPTIONS' => 1,
- 'AM_RUN_LOG' => 1,
+ '_LT_COMPILER_OPTION' => 1,
'_AM_OUTPUT_DEPENDENCY_COMMANDS' => 1,
- 'AC_LTDL_SYS_DLOPEN_DEPLIBS' => 1,
- 'AC_LIBTOOL_SYS_OLD_ARCHIVE' => 1,
+ 'AM_RUN_LOG' => 1,
'AC_LIBTOOL_PICMODE' => 1,
- 'AC_CHECK_LIBM' => 1,
+ 'AC_LIBTOOL_SYS_OLD_ARCHIVE' => 1,
+ 'AC_LTDL_SYS_DLOPEN_DEPLIBS' => 1,
'LT_PATH_LD' => 1,
+ 'AC_CHECK_LIBM' => 1,
'AC_LIBTOOL_SYS_LIB_STRIP' => 1,
'_AM_MANGLE_OPTION' => 1,
- 'AC_LIBTOOL_SYS_MAX_CMD_LEN' => 1,
'AC_LTDL_SYMBOL_USCORE' => 1,
+ 'AC_LIBTOOL_SYS_MAX_CMD_LEN' => 1,
'AM_SET_DEPDIR' => 1,
- '_LT_LIBSOURCES' => 1,
'_LT_CC_BASENAME' => 1,
+ '_LT_LIBSOURCES' => 1,
'_LT_LIBOBJ' => 1
}
], 'Autom4te::Request' ),
@@ -219,24 +219,24 @@
'configure.ac'
],
{
- '_LT_AC_TAGCONFIG' => 1,
'AM_PROG_F77_C_O' => 1,
- 'AC_INIT' => 1,
+ '_LT_AC_TAGCONFIG' => 1,
'm4_pattern_forbid' => 1,
+ 'AC_INIT' => 1,
'AC_CANONICAL_TARGET' => 1,
- 'AC_CONFIG_LIBOBJ_DIR' => 1,
'AC_SUBST' => 1,
- 'AC_CANONICAL_HOST' => 1,
+ 'AC_CONFIG_LIBOBJ_DIR' => 1,
'AC_FC_SRCEXT' => 1,
+ 'AC_CANONICAL_HOST' => 1,
'AC_PROG_LIBTOOL' => 1,
'AM_INIT_AUTOMAKE' => 1,
'AC_CONFIG_SUBDIRS' => 1,
'AM_AUTOMAKE_VERSION' => 1,
'LT_CONFIG_LTDL_DIR' => 1,
'AC_CONFIG_LINKS' => 1,
'AC_REQUIRE_AUX_FILE' => 1,
- 'LT_SUPPORTED_TAG' => 1,
'm4_sinclude' => 1,
+ 'LT_SUPPORTED_TAG' => 1,
'AM_MAINTAINER_MODE' => 1,
'AM_GNU_GETTEXT_INTL_SUBDIR' => 1,
'_m4_warn' => 1,
@@ -253,11 +253,11 @@
'AH_OUTPUT' => 1,
'_AM_SUBST_NOTMAKE' => 1,
'AC_CONFIG_AUX_DIR' => 1,
- 'm4_pattern_allow' => 1,
- 'AM_PROG_CC_C_O' => 1,
'sinclude' => 1,
- 'AM_CONDITIONAL' => 1,
+ 'AM_PROG_CC_C_O' => 1,
+ 'm4_pattern_allow' => 1,
'AC_CANONICAL_SYSTEM' => 1,
+ 'AM_CONDITIONAL' => 1,
'AC_CONFIG_HEADERS' => 1,
'AC_DEFINE_TRACE_LITERAL' => 1,
'm4_include' => 1,
View
@@ -1,5 +1,8 @@
## Process this file with automake to produce Makefile.in
-bin_PROGRAMS = barbershop
+bin_PROGRAMS = barbershop benchmark
barbershop_SOURCES = barbershop.c barbershop.h bst.c bst.h scores.c scores.h stats.h
barbershop_CFLAGS = $(OPTIMIZATION) -Wall $(ARCH) $(PROF)
+
+benchmark_SOURCES = benchmark.c
+benchmark_CFLAGS = $(OPTIMIZATION) -Wall $(ARCH) $(PROF)
View
@@ -32,7 +32,7 @@ PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
-bin_PROGRAMS = barbershop$(EXEEXT)
+bin_PROGRAMS = barbershop$(EXEEXT) benchmark$(EXEEXT)
subdir = src
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -52,6 +52,12 @@ barbershop_LDADD = $(LDADD)
barbershop_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(barbershop_CFLAGS) \
$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+am_benchmark_OBJECTS = benchmark-benchmark.$(OBJEXT)
+benchmark_OBJECTS = $(am_benchmark_OBJECTS)
+benchmark_LDADD = $(LDADD)
+benchmark_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(benchmark_CFLAGS) \
+ $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
DEFAULT_INCLUDES = -I. -I$(top_builddir)@am__isrc@
depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp
am__depfiles_maybe = depfiles
@@ -64,8 +70,8 @@ CCLD = $(CC)
LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
$(LDFLAGS) -o $@
-SOURCES = $(barbershop_SOURCES)
-DIST_SOURCES = $(barbershop_SOURCES)
+SOURCES = $(barbershop_SOURCES) $(benchmark_SOURCES)
+DIST_SOURCES = $(barbershop_SOURCES) $(benchmark_SOURCES)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@@ -181,6 +187,8 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
barbershop_SOURCES = barbershop.c barbershop.h bst.c bst.h scores.c scores.h stats.h
barbershop_CFLAGS = $(OPTIMIZATION) -Wall $(ARCH) $(PROF)
+benchmark_SOURCES = benchmark.c
+benchmark_CFLAGS = $(OPTIMIZATION) -Wall $(ARCH) $(PROF)
all: all-am
.SUFFIXES:
@@ -245,6 +253,9 @@ clean-binPROGRAMS:
barbershop$(EXEEXT): $(barbershop_OBJECTS) $(barbershop_DEPENDENCIES)
@rm -f barbershop$(EXEEXT)
$(barbershop_LINK) $(barbershop_OBJECTS) $(barbershop_LDADD) $(LIBS)
+benchmark$(EXEEXT): $(benchmark_OBJECTS) $(benchmark_DEPENDENCIES)
+ @rm -f benchmark$(EXEEXT)
+ $(benchmark_LINK) $(benchmark_OBJECTS) $(benchmark_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
@@ -255,6 +266,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/barbershop-barbershop.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/barbershop-bst.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/barbershop-scores.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/benchmark-benchmark.Po@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@@ -319,6 +331,20 @@ barbershop-scores.obj: scores.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(barbershop_CFLAGS) $(CFLAGS) -c -o barbershop-scores.obj `if test -f 'scores.c'; then $(CYGPATH_W) 'scores.c'; else $(CYGPATH_W) '$(srcdir)/scores.c'; fi`
+benchmark-benchmark.o: benchmark.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(benchmark_CFLAGS) $(CFLAGS) -MT benchmark-benchmark.o -MD -MP -MF $(DEPDIR)/benchmark-benchmark.Tpo -c -o benchmark-benchmark.o `test -f 'benchmark.c' || echo '$(srcdir)/'`benchmark.c
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/benchmark-benchmark.Tpo $(DEPDIR)/benchmark-benchmark.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='benchmark.c' object='benchmark-benchmark.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(benchmark_CFLAGS) $(CFLAGS) -c -o benchmark-benchmark.o `test -f 'benchmark.c' || echo '$(srcdir)/'`benchmark.c
+
+benchmark-benchmark.obj: benchmark.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(benchmark_CFLAGS) $(CFLAGS) -MT benchmark-benchmark.obj -MD -MP -MF $(DEPDIR)/benchmark-benchmark.Tpo -c -o benchmark-benchmark.obj `if test -f 'benchmark.c'; then $(CYGPATH_W) 'benchmark.c'; else $(CYGPATH_W) '$(srcdir)/benchmark.c'; fi`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/benchmark-benchmark.Tpo $(DEPDIR)/benchmark-benchmark.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='benchmark.c' object='benchmark-benchmark.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(benchmark_CFLAGS) $(CFLAGS) -c -o benchmark-benchmark.obj `if test -f 'benchmark.c'; then $(CYGPATH_W) 'benchmark.c'; else $(CYGPATH_W) '$(srcdir)/benchmark.c'; fi`
+
mostlyclean-libtool:
-rm -f *.lo
View
@@ -33,6 +33,7 @@ THE SOFTWARE.
#include <errno.h>
#include <err.h>
#include <time.h>
+#include <assert.h>
#include "scores.h"
#include "bst.h"
@@ -101,7 +102,7 @@ void on_read(int fd, short ev, void *arg) {
int item_id = atoi(tokens[KEY_TOKEN].value);
int score = atoi(tokens[VALUE_TOKEN].value);
- Position lookup = Find( item_id, items );
+ Position lookup = Find(item_id, items);
if (lookup == NULL) {
items = Insert(item_id, score, items);
scores = promoteItem(scores, score, item_id, -1);
@@ -114,13 +115,14 @@ void on_read(int fd, short ev, void *arg) {
} else {
lookup->score += score;
}
+ assert(lookup->score > old_score);
scores = promoteItem(scores, lookup->score, item_id, old_score);
}
app_stats.updates += 1;
reply(fd, "OK\r\n");
} else if (ntokens == 2 && strcmp(tokens[COMMAND_TOKEN].value, "next") == 0) {
- int next = -1;
- scores = NextItem(scores, next);
+ int next;
+ scores = NextItem(scores, &next);
if (next != -1) {
Position lookup = Find( next, items );
if (lookup != NULL) {
@@ -144,12 +146,6 @@ void on_read(int fd, short ev, void *arg) {
sprintf(out, "STAT pools_gc %d\r\n", app_stats.pools_gc); reply(fd, out);
sprintf(out, "STAT items_gc %d\r\n", app_stats.items_gc); reply(fd, out);
reply(fd, "END\r\n");
- /*
- printf("Dumping items tree:\n");
- DumpItems(items);
- printf("Dumping score buckets:\n");
- DumpScores(scores);
- */
} else {
reply(fd, "ERROR\r\n");
}
Oops, something went wrong.

0 comments on commit ca54a85

Please sign in to comment.