gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r5136 - GNUnet/src/applications/sqstore_sqlite


From: gnunet
Subject: [GNUnet-SVN] r5136 - GNUnet/src/applications/sqstore_sqlite
Date: Sun, 24 Jun 2007 03:35:55 -0600 (MDT)

Author: grothoff
Date: 2007-06-24 03:35:52 -0600 (Sun, 24 Jun 2007)
New Revision: 5136

Added:
   GNUnet/src/applications/sqstore_sqlite/sqlitetest3.c
Modified:
   GNUnet/src/applications/sqstore_sqlite/Makefile.am
Log:
new sqlite benchmark

Modified: GNUnet/src/applications/sqstore_sqlite/Makefile.am
===================================================================
--- GNUnet/src/applications/sqstore_sqlite/Makefile.am  2007-06-24 09:16:56 UTC 
(rev 5135)
+++ GNUnet/src/applications/sqstore_sqlite/Makefile.am  2007-06-24 09:35:52 UTC 
(rev 5136)
@@ -10,7 +10,8 @@
 
 check_PROGRAMS = \
   sqlitetest \
-  sqlitetest2
+  sqlitetest2 \
+  sqlitetest3
 
 TESTS = $(check_PROGRAMS)
 
@@ -41,3 +42,12 @@
  $(top_builddir)/src/server/libgnunetcore.la  \
  $(top_builddir)/src/util/config_impl/libgnunetutil_config.la  \
  $(top_builddir)/src/util/libgnunetutil.la  
+
+
+
+sqlitetest3_SOURCES = \
+ sqlitetest3.c 
+sqlitetest3_LDADD = \
+ $(top_builddir)/src/server/libgnunetcore.la  \
+ $(top_builddir)/src/util/config_impl/libgnunetutil_config.la  \
+ $(top_builddir)/src/util/libgnunetutil.la  

Added: GNUnet/src/applications/sqstore_sqlite/sqlitetest3.c
===================================================================
--- GNUnet/src/applications/sqstore_sqlite/sqlitetest3.c                        
        (rev 0)
+++ GNUnet/src/applications/sqstore_sqlite/sqlitetest3.c        2007-06-24 
09:35:52 UTC (rev 5136)
@@ -0,0 +1,206 @@
+/*
+     This file is part of GNUnet.
+     (C) 2004, 2005, 2006, 2007 Christian Grothoff (and other contributing 
authors)
+
+     GNUnet is free software; you can redistribute it and/or modify
+     it under the terms of the GNU General Public License as published
+     by the Free Software Foundation; either version 2, or (at your
+     option) any later version.
+
+     GNUnet is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
+
+     You should have received a copy of the GNU General Public License
+     along with GNUnet; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+     Boston, MA 02111-1307, USA.
+*/
+/*
+ * @file applications/sqstore_sqlite/sqlitetest3.c
+ * @brief Profile sqstore iterators.
+ * @author Christian Grothoff
+ */
+
+#include "platform.h"
+#include "gnunet_util.h"
+#include "gnunet_util_cron.h"
+#include "gnunet_util_crypto.h"
+#include "gnunet_util_config_impl.h"
+#include "gnunet_protocols.h"
+#include "gnunet_sqstore_service.h"
+#include "core.h"
+
+/**
+ * Target datastore size (in bytes).  Realistic sizes are
+ * more like 16 GB (not the default of 16 MB); however,
+ * those take too long to run them in the usual "make check"
+ * sequence.  Hence the value used for shipping is tiny.
+ */
+#define MAX_SIZE 1024LL * 1024 * 128
+
+#define ITERATIONS 10
+
+/**
+ * Number of put operations equivalent to 1/10th of MAX_SIZE
+ */
+#define PUT_10 (MAX_SIZE / 32 / 1024 / ITERATIONS)
+
+
+/**
+ * Name of the database on disk.
+ */
+#define DB_NAME "/tmp/gnunet-sqlite-sqstore-perf/data/fs/content/gnunet.dat"
+
+static unsigned long long stored_bytes;
+
+static unsigned long long stored_entries;
+
+static unsigned long long stored_ops;
+
+static cron_t start_time;
+
+static int putValue(SQstore_ServiceAPI * api,
+                   int i) {
+  Datastore_Value * value;
+  size_t size;
+  static HashCode512 key;
+  static int ic;
+
+  /* most content is 32k */
+  size = sizeof(Datastore_Value) + 32 * 1024;
+  if (weak_randomi(16) == 0) /* but some of it is less! */
+    size = sizeof(Datastore_Value) + weak_randomi(32 * 1024);
+  size = size - (size & 7); /* always multiple of 8 */
+
+  /* generate random key */
+  hash(&key,
+       sizeof(HashCode512),
+       &key);
+  value = MALLOC(size);
+  value->size = htonl(size);
+  value->type = htonl(i);
+  value->prio = htonl(weak_randomi(100));
+  value->anonymityLevel = htonl(i);
+  value->expirationTime = htonll(get_time() + weak_randomi(1000));
+  memset(&value[1],
+        i,
+        size - sizeof(Datastore_Value));
+  if (OK != api->put(&key, value)) {
+    FREE(value);
+    fprintf(stderr, "E");
+    return SYSERR;
+  }
+  ic++;
+#if REPORT_ID
+  if (ic % REP_FREQ == 0)
+    fprintf(stderr, "I");
+#endif
+  stored_bytes += ntohl(value->size);
+  stored_ops++;
+  stored_entries++;
+  FREE(value);
+  return OK;
+}
+
+static int
+iterateDummy(const HashCode512 * key,
+            const Datastore_Value * val,
+            void * cls) {
+  return OK;
+}
+
+static int test(SQstore_ServiceAPI * api) {
+  int i;
+  int j;
+  cron_t start;
+  cron_t end;
+
+  for (i=0;i<ITERATIONS;i++) {
+    /* insert data equivalent to 1/10th of MAX_SIZE */
+    start = get_time();
+    for (j=0;j<PUT_10;j++) {
+      if (OK != putValue(api, j))
+       break;
+      if (GNUNET_SHUTDOWN_TEST() == YES)
+       break;
+    }
+    end = get_time();
+    printf("\n%3u insertion              took %20llums\n", i, end-start);
+    if (GNUNET_SHUTDOWN_TEST() == YES)
+      break;
+    start = get_time();
+    api->iterateLowPriority(0, &iterateDummy, api);
+    end = get_time();
+    printf("\n%3u low priority iteration took %20llums\n", i, end-start);
+    if (GNUNET_SHUTDOWN_TEST() == YES)
+      break;
+    start = get_time();
+    api->iterateExpirationTime(0, &iterateDummy, api);
+    end = get_time();
+    printf("\n%3u expiration t iteration took %20llums\n", i, end-start);
+    if (GNUNET_SHUTDOWN_TEST() == YES)
+      break;
+    start = get_time();
+    api->iterateNonAnonymous(0, NO, &iterateDummy, api);
+    end = get_time();
+    printf("\n%3u non anonymou iteration took %20llums\n", i, end-start);
+    if (GNUNET_SHUTDOWN_TEST() == YES)
+      break;
+    start = get_time();
+    api->iterateNonAnonymous(0, YES, &iterateDummy, api);
+    end = get_time();
+    printf("\n%3u non anon YES iteration took %20llums\n", i, end-start);
+    if (GNUNET_SHUTDOWN_TEST() == YES)
+      break;
+    start = get_time();
+    api->iterateMigrationOrder(&iterateDummy, api);
+    end = get_time();
+    printf("\n%3u migration or iteration took %20llums\n", i, end-start);
+    if (GNUNET_SHUTDOWN_TEST() == YES)
+      break;
+    start = get_time();
+    api->iterateAllNow(&iterateDummy, api);
+    end = get_time();
+    printf("\n%3u all now      iteration took %20llums\n", i, end-start);
+    if (GNUNET_SHUTDOWN_TEST() == YES)
+      break;
+  }
+  api->drop();
+  return OK;
+}
+
+int main(int argc, char *argv[]) {
+  SQstore_ServiceAPI * api;
+  int ok;
+  struct GC_Configuration * cfg;
+  struct CronManager * cron;
+
+  cfg = GC_create_C_impl();
+  if (-1 == GC_parse_configuration(cfg,
+                                  "check.conf")) {
+    GC_free(cfg);
+    return -1;
+  }
+  cron = cron_create(NULL);
+  initCore(NULL,
+          cfg,
+          cron,
+          NULL);
+  api = requestService("sqstore");
+  if (api != NULL) {
+    start_time = get_time();
+    ok = test(api);
+    releaseService(api);
+  } else
+    ok = SYSERR;
+  doneCore();
+  cron_destroy(cron);
+  GC_free(cfg);
+  if (ok == SYSERR)
+    return 1;
+  return 0;
+}
+
+/* end of sqlitetest3.c */


Property changes on: GNUnet/src/applications/sqstore_sqlite/sqlitetest3.c
___________________________________________________________________
Name: svn:eol-style
   + native





reply via email to

[Prev in Thread] Current Thread [Next in Thread]