Permalink
Browse files

initial commit

  • Loading branch information...
0 parents commit c62b949db8a6aff2def234d47bc541a4000f1192 @ingenthr ingenthr committed Jun 18, 2009
Showing with 3,093 additions and 0 deletions.
  1. +385 −0 LICENSE.txt
  2. +5 −0 Makefile.am
  3. +42 −0 boxmuller.c
  4. +107 −0 config/bootstrap
  5. +97 −0 configure.ac
  6. +752 −0 libmemc.c
  7. +59 −0 libmemc.h
  8. +1,358 −0 main.c
  9. +229 −0 metrics.c
  10. +59 −0 metrics.h

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,5 @@
+AUTOMAKE_OPTIONS = foreign
+bin_PROGRAMS = testclient
+
+testclient_SOURCES = main.c libmemc.c libmemc.h boxmuller.c metrics.c
+
@@ -0,0 +1,42 @@
+/* code borrowed from ftp://ftp.taygeta.com/pub/c/boxmuller.c */
+/* boxmuller.c Implements the Polar form of the Box-Muller
+ Transformation
+
+ (c) Copyright 1994, Everett F. Carter Jr.
+ Permission is granted by the author to use
+ this software for any application provided this
+ copyright notice is preserved.
+
+*/
+#include <math.h>
+#include <stdlib.h>
+
+double box_muller(double m, double s) /* normal random variate generator */
+{ /* mean m, standard deviation s */
+ double x1, x2, w, y1;
+ static double y2;
+ static int use_last = 0;
+
+ if (use_last) /* use value from previous call */
+ {
+ y1 = y2;
+ use_last = 0;
+ }
+ else
+ {
+ do {
+ x1 = 2.0 * drand48() - 1.0;
+ x2 = 2.0 * drand48() - 1.0;
+ w = x1 * x1 + x2 * x2;
+ } while ( w >= 1.0 );
+
+ w = sqrt( (-2.0 * log( w ) ) / w );
+ y1 = x1 * w;
+ y2 = x2 * w;
+ use_last = 1;
+ }
+
+ double result = ( m + y1 * s );
+
+ return result;
+}
@@ -0,0 +1,107 @@
+#!/usr/bin/env bash
+# Taken from lighthttpd server (BSD). Thanks Jan!
+# then taken from libmemcached :)
+# Run this to generate all the initial makefiles, etc.
+
+die() { echo "$@"; exit 1; }
+
+# LIBTOOLIZE=${LIBTOOLIZE:-libtoolize}
+LIBTOOLIZE_FLAGS=" --automake --copy --force"
+# ACLOCAL=${ACLOCAL:-aclocal}
+ACLOCAL_FLAGS="-I m4"
+# AUTOHEADER=${AUTOHEADER:-autoheader}
+# AUTOMAKE=${AUTOMAKE:-automake}
+AUTOMAKE_FLAGS="--add-missing --copy --force"
+# AUTOCONF=${AUTOCONF:-autoconf}
+
+ARGV0=$0
+ARGS="$@"
+
+
+run() {
+ echo "$ARGV0: running \`$@' $ARGS"
+ $@ $ARGS
+}
+
+## jump out if one of the programs returns 'false'
+set -e
+
+## We do not currently support glibtoolize
+if test x$LIBTOOLIZE = x; then
+ if test \! "x`which glibtoolize 2> /dev/null | grep -v '^no'`" = x; then
+ LIBTOOLIZE=glibtoolize
+ elif test \! "x`which libtoolize-1.5 2> /dev/null | grep -v '^no'`" = x; then
+ LIBTOOLIZE=libtoolize-1.5
+ elif test \! "x`which libtoolize 2> /dev/null | grep -v '^no'`" = x; then
+ LIBTOOLIZE=libtoolize
+ else
+ echo "libtoolize 1.5.x wasn't found, exiting"; exit 0
+ fi
+fi
+
+## suse has aclocal and aclocal-1.9
+if test x$ACLOCAL = x; then
+ if test \! "x`which aclocal-1.10 2> /dev/null | grep -v '^no'`" = x; then
+ ACLOCAL=aclocal-1.10
+ elif test \! "x`which aclocal-1.9 2> /dev/null | grep -v '^no'`" = x; then
+ ACLOCAL=aclocal-1.9
+ elif test \! "x`which aclocal19 2> /dev/null | grep -v '^no'`" = x; then
+ ACLOCAL=aclocal19
+ elif test \! "x`which aclocal 2> /dev/null | grep -v '^no'`" = x; then
+ ACLOCAL=aclocal
+ else
+ echo "automake 1.9.x (aclocal) wasn't found, exiting"; exit 0
+ fi
+fi
+
+if test x$AUTOMAKE = x; then
+ if test \! "x`which automake-1.10 2> /dev/null | grep -v '^no'`" = x; then
+ AUTOMAKE=automake-1.10
+ elif test \! "x`which automake-1.9 2> /dev/null | grep -v '^no'`" = x; then
+ AUTOMAKE=automake-1.9
+ elif test \! "x`which automake19 2> /dev/null | grep -v '^no'`" = x; then
+ AUTOMAKE=automake19
+ elif test \! "x`which automake 2> /dev/null | grep -v '^no'`" = x; then
+ AUTOMAKE=automake
+ else
+ echo "automake 1.9.x wasn't found, exiting"; exit 0
+ fi
+fi
+
+
+## macosx has autoconf-2.59 and autoconf-2.60
+if test x$AUTOCONF = x; then
+ if test \! "x`which autoconf-2.59 2> /dev/null | grep -v '^no'`" = x; then
+ AUTOCONF=autoconf-2.59
+ elif test \! "x`which autoconf259 2> /dev/null | grep -v '^no'`" = x; then
+ AUTOCONF=autoconf259
+ elif test \! "x`which autoconf 2> /dev/null | grep -v '^no'`" = x; then
+ AUTOCONF=autoconf
+ else
+ echo "autoconf 2.59+ wasn't found, exiting"; exit 0
+ fi
+fi
+
+if test x$AUTOHEADER = x; then
+ if test \! "x`which autoheader-2.59 2> /dev/null | grep -v '^no'`" = x; then
+ AUTOHEADER=autoheader-2.59
+ elif test \! "x`which autoheader259 2> /dev/null | grep -v '^no'`" = x; then
+ AUTOHEADER=autoheader259
+ elif test \! "x`which autoheader 2> /dev/null | grep -v '^no'`" = x; then
+ AUTOHEADER=autoheader
+ else
+ echo "autoconf 2.59+ (autoheader) wasn't found, exiting"; exit 0
+ fi
+fi
+
+
+# --force means overwrite ltmain.sh script if it already exists
+# run $LIBTOOLIZE $LIBTOOLIZE_FLAGS || die "Can't execute libtoolize"
+
+run $ACLOCAL $ACLOCAL_FLAGS || die "Can't execute aclocal"
+run $AUTOHEADER || die "Can't execute autoheader"
+
+# --add-missing instructs automake to install missing auxiliary files
+# and --force to overwrite them if they already exist
+run $AUTOMAKE $AUTOMAKE_FLAGS || die "Can't execute automake"
+run $AUTOCONF || die "Can't execute autoconf"
@@ -0,0 +1,97 @@
+AC_PREREQ(2.52)
+AC_INIT(memcachebench, 0.5.0, ingenthr@cep.net)
+AC_CONFIG_SRCDIR(main.c)
+AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
+AM_CONFIG_HEADER(config.h)
+
+AC_PROG_CC
+AC_PROG_CC_C99
+AM_PROG_CC_C_O
+AC_PROG_INSTALL
+AC_C_CONST
+
+AC_ARG_ENABLE(64bit,
+ [AS_HELP_STRING([--enable-64bit],[build 64bit version])])
+if test "x$enable_64bit" == "xyes"
+then
+ org_cflags=$CFLAGS
+ CFLAGS=-m64
+ AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM([], [dnl
+return sizeof(void*) == 8 ? 0 : 1;
+ ])
+ ],[
+ CFLAGS="-m64 $org_cflags"
+ ],[
+ AC_MSG_ERROR([Don't know how to build a 64-bit object.])
+ ])
+fi
+
+AC_ARG_WITH(libmemcached,
+ AS_HELP_STRING(--with-libmemcached,[Add support for libmemcached]),
+ [
+ if test "x$withval" = "xno"
+ then
+ without_libmemcached=true
+ else
+ if test "x$withval" != "x"
+ then
+ CFLAGS="-I$withval/include $CFLAGS"
+ CPPFLAGS="-I$withval/include $CPPFLAGS"
+ # TODO: linux should have --rpath instead of -R
+ LDFLAGS="-L$withval/lib -Wl,-R$withval/lib"
+ fi
+ fi
+ ]
+)
+
+AC_ARG_WITH(memcached,
+ AS_HELP_STRING(--with-memcached,[Specify location of memcached installation]),
+ [
+ if test "x$withval" = "xno"
+ then
+ without_memcached=true
+ else
+ if test "x$withval" != "x"
+ then
+ CFLAGS="-I$withval/include $CFLAGS"
+ CPPFLAGS="-I$withval/include $CPPFLAGS"
+ fi
+ fi
+ ]
+)
+
+# Currently I only support GCC and Sun Studio
+if test "$GCC" = "yes"
+then
+ CFLAGS="-Wall -O3 $CFLAGS"
+else
+ CFLAGS="-Xa -xstrconst -mt -xunroll=2 -xprefetch=auto -xprefetch_level=3 $CFLAGS"
+fi
+
+AC_SEARCH_LIBS(socket, socket)
+AC_SEARCH_LIBS(gethostbyname, nsl)
+AC_SEARCH_LIBS(log, m)
+AC_SEARCH_LIBS(sqrt, m)
+AC_SEARCH_LIBS(pthread_create, pthread)
+
+AC_CHECK_HEADER(sys/mman.h, AC_DEFINE(HAVE_MMAN_H, 1, [Define if you have sys/mman.h]))
+AC_CHECK_FUNC(mmap, AC_DEFINE(HAVE_MMAP, 1, [Define if you have mmap]))
+AC_CHECK_FUNC(madvise, AC_DEFINE(HAVE_MADVISE, 1, [Define if you have madvise]))
+AC_CHECK_FUNC(gethrtime, AC_DEFINE(HAVE_GETHRTIME, 1, [Define if you have gethrtime]))
+
+if test "$without_libmemcaced" != "true"
+then
+ AC_CHECK_HEADER(libmemcached/memcached.h,
+ AC_SEARCH_LIBS(memcached_create, memcached,
+ AC_DEFINE(HAVE_LIBMEMCACHED, 1, [Define if you have libmemcached/memcached.h])))
+fi
+
+if test "$without_memcaced" != "true"
+then
+ AC_CHECK_HEADER(memcached/protocol_binary.h,
+ AC_DEFINE(HAVE_PROTOCOL_BINARY, 1, [Define if you have memcached/protocol_binary.h]))
+fi
+
+AC_CONFIG_FILES(Makefile)
+AC_OUTPUT
Oops, something went wrong.

0 comments on commit c62b949

Please sign in to comment.