aboutsummaryrefslogtreecommitdiff
path: root/src/datacache/perf_datacache.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-15 21:54:06 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-15 21:54:06 +0000
commit5746309cb4be2073d550ad7a6885e918631dbc38 (patch)
tree89455bc4aadf977816b38df13f990372cd81d71a /src/datacache/perf_datacache.c
parent6fd3e715cae09fa6e657c96f1c6f9711ee51f42f (diff)
downloadgnunet-5746309cb4be2073d550ad7a6885e918631dbc38.tar.gz
gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.zip
indentation
Diffstat (limited to 'src/datacache/perf_datacache.c')
-rw-r--r--src/datacache/perf_datacache.c47
1 files changed, 19 insertions, 28 deletions
diff --git a/src/datacache/perf_datacache.c b/src/datacache/perf_datacache.c
index 3af76dbb6..a5dc02362 100644
--- a/src/datacache/perf_datacache.c
+++ b/src/datacache/perf_datacache.c
@@ -44,10 +44,9 @@ static const char *plugin_name;
44 44
45 45
46static int 46static int
47checkIt (void *cls, 47checkIt (void *cls, struct GNUNET_TIME_Absolute exp,
48 struct GNUNET_TIME_Absolute exp, 48 const GNUNET_HashCode * key, size_t size, const char *data,
49 const GNUNET_HashCode * key, 49 enum GNUNET_BLOCK_Type type)
50 size_t size, const char *data, enum GNUNET_BLOCK_Type type)
51{ 50{
52 if ((size == sizeof (GNUNET_HashCode)) && (0 == memcmp (data, cls, size))) 51 if ((size == sizeof (GNUNET_HashCode)) && (0 == memcmp (data, cls, size)))
53 found++; 52 found++;
@@ -56,9 +55,8 @@ checkIt (void *cls,
56 55
57 56
58static void 57static void
59run (void *cls, 58run (void *cls, char *const *args, const char *cfgfile,
60 char *const *args, 59 const struct GNUNET_CONFIGURATION_Handle *cfg)
61 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
62{ 60{
63 struct GNUNET_DATACACHE_Handle *h; 61 struct GNUNET_DATACACHE_Handle *h;
64 GNUNET_HashCode k; 62 GNUNET_HashCode k;
@@ -86,21 +84,17 @@ run (void *cls,
86 if (0 == i % (ITERATIONS / 80)) 84 if (0 == i % (ITERATIONS / 80))
87 fprintf (stderr, "."); 85 fprintf (stderr, ".");
88 GNUNET_CRYPTO_hash (&k, sizeof (GNUNET_HashCode), &n); 86 GNUNET_CRYPTO_hash (&k, sizeof (GNUNET_HashCode), &n);
89 ASSERT (GNUNET_OK == GNUNET_DATACACHE_put (h, 87 ASSERT (GNUNET_OK ==
90 &k, 88 GNUNET_DATACACHE_put (h, &k, sizeof (GNUNET_HashCode),
91 sizeof (GNUNET_HashCode), 89 (const char *) &n, 1 + i % 16, exp));
92 (const char *) &n,
93 1 + i % 16, exp));
94 k = n; 90 k = n;
95 } 91 }
96 fprintf (stderr, "\n"); 92 fprintf (stderr, "\n");
97 fprintf (stdout, "Stored %u items in %llums\n", 93 fprintf (stdout, "Stored %u items in %llums\n", ITERATIONS,
98 ITERATIONS, 94 (unsigned long long) GNUNET_TIME_absolute_get_duration (start).
99 (unsigned long long) 95 rel_value);
100 GNUNET_TIME_absolute_get_duration (start).rel_value);
101 GNUNET_snprintf (gstr, sizeof (gstr), "DATACACHE-%s", plugin_name); 96 GNUNET_snprintf (gstr, sizeof (gstr), "DATACACHE-%s", plugin_name);
102 GAUGER (gstr, 97 GAUGER (gstr, "Time to PUT item in datacache",
103 "Time to PUT item in datacache",
104 GNUNET_TIME_absolute_get_duration (start).rel_value / ITERATIONS, 98 GNUNET_TIME_absolute_get_duration (start).rel_value / ITERATIONS,
105 "ms/item"); 99 "ms/item");
106 start = GNUNET_TIME_absolute_get (); 100 start = GNUNET_TIME_absolute_get ();
@@ -117,12 +111,10 @@ run (void *cls,
117 fprintf (stdout, 111 fprintf (stdout,
118 "Found %u/%u items in %llums (%u were deleted during storage processing)\n", 112 "Found %u/%u items in %llums (%u were deleted during storage processing)\n",
119 found, ITERATIONS, 113 found, ITERATIONS,
120 (unsigned long long) 114 (unsigned long long) GNUNET_TIME_absolute_get_duration (start).
121 GNUNET_TIME_absolute_get_duration (start).rel_value, 115 rel_value, ITERATIONS - found);
122 ITERATIONS - found);
123 if (found > 0) 116 if (found > 0)
124 GAUGER (gstr, 117 GAUGER (gstr, "Time to GET item from datacache",
125 "Time to GET item from datacache",
126 GNUNET_TIME_absolute_get_duration (start).rel_value / found, 118 GNUNET_TIME_absolute_get_duration (start).rel_value / found,
127 "ms/item"); 119 "ms/item");
128 GNUNET_DATACACHE_destroy (h); 120 GNUNET_DATACACHE_destroy (h);
@@ -170,13 +162,12 @@ main (int argc, char *argv[])
170 else 162 else
171 pos = (char *) plugin_name; 163 pos = (char *) plugin_name;
172 164
173 GNUNET_snprintf (cfg_name, 165 GNUNET_snprintf (cfg_name, sizeof (cfg_name), "perf_datacache_data_%s.conf",
174 sizeof (cfg_name), 166 plugin_name);
175 "perf_datacache_data_%s.conf", plugin_name);
176 if (pos != plugin_name) 167 if (pos != plugin_name)
177 pos[0] = '.'; 168 pos[0] = '.';
178 GNUNET_PROGRAM_run ((sizeof (xargv) / sizeof (char *)) - 1, 169 GNUNET_PROGRAM_run ((sizeof (xargv) / sizeof (char *)) - 1, xargv,
179 xargv, "perf-datacache", "nohelp", options, &run, NULL); 170 "perf-datacache", "nohelp", options, &run, NULL);
180 if (ok != 0) 171 if (ok != 0)
181 fprintf (stderr, "Missed some perfcases: %d\n", ok); 172 fprintf (stderr, "Missed some perfcases: %d\n", ok);
182 return ok; 173 return ok;