aboutsummaryrefslogtreecommitdiff
path: root/src/datacache/perf_datacache.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-15 21:46:35 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-15 21:46:35 +0000
commit502af2167f7c218366666ca4944bd7cc54b5b19a (patch)
treea91fec5cc9769d260640bd91c6633cb9cf395524 /src/datacache/perf_datacache.c
parent03af5a603b7cc53432249d5854cd412aa90dde0d (diff)
downloadgnunet-502af2167f7c218366666ca4944bd7cc54b5b19a.tar.gz
gnunet-502af2167f7c218366666ca4944bd7cc54b5b19a.zip
indentation
Diffstat (limited to 'src/datacache/perf_datacache.c')
-rw-r--r--src/datacache/perf_datacache.c119
1 files changed, 56 insertions, 63 deletions
diff --git a/src/datacache/perf_datacache.c b/src/datacache/perf_datacache.c
index a3c59ff4f..3af76dbb6 100644
--- a/src/datacache/perf_datacache.c
+++ b/src/datacache/perf_datacache.c
@@ -45,14 +45,11 @@ static const char *plugin_name;
45 45
46static int 46static int
47checkIt (void *cls, 47checkIt (void *cls,
48 struct GNUNET_TIME_Absolute exp, 48 struct GNUNET_TIME_Absolute exp,
49 const GNUNET_HashCode * key, 49 const GNUNET_HashCode * key,
50 size_t size, 50 size_t size, const char *data, enum GNUNET_BLOCK_Type type)
51 const char *data,
52 enum GNUNET_BLOCK_Type type)
53{ 51{
54 if ( (size == sizeof (GNUNET_HashCode)) && 52 if ((size == sizeof (GNUNET_HashCode)) && (0 == memcmp (data, cls, size)))
55 (0 == memcmp (data, cls, size)) )
56 found++; 53 found++;
57 return GNUNET_OK; 54 return GNUNET_OK;
58} 55}
@@ -61,8 +58,7 @@ checkIt (void *cls,
61static void 58static void
62run (void *cls, 59run (void *cls,
63 char *const *args, 60 char *const *args,
64 const char *cfgfile, 61 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
65 const struct GNUNET_CONFIGURATION_Handle *cfg)
66{ 62{
67 struct GNUNET_DATACACHE_Handle *h; 63 struct GNUNET_DATACACHE_Handle *h;
68 GNUNET_HashCode k; 64 GNUNET_HashCode k;
@@ -71,66 +67,64 @@ run (void *cls,
71 struct GNUNET_TIME_Absolute start; 67 struct GNUNET_TIME_Absolute start;
72 unsigned int i; 68 unsigned int i;
73 char gstr[128]; 69 char gstr[128];
74 70
75 ok = 0; 71 ok = 0;
76 h = GNUNET_DATACACHE_create (cfg, 72 h = GNUNET_DATACACHE_create (cfg, "perfcache");
77 "perfcache");
78 73
79 if (h == NULL) 74 if (h == NULL)
80 { 75 {
81 fprintf (stderr, 76 fprintf (stderr,
82 "Failed to initialize datacache. Database likely not setup, skipping test.\n"); 77 "Failed to initialize datacache. Database likely not setup, skipping test.\n");
83 return; 78 return;
84 } 79 }
85 exp = GNUNET_TIME_absolute_get (); 80 exp = GNUNET_TIME_absolute_get ();
86 start = exp; 81 start = exp;
87 exp.abs_value += 5 * 60 * 1000; 82 exp.abs_value += 5 * 60 * 1000;
88 memset (&k, 0, sizeof (GNUNET_HashCode)); 83 memset (&k, 0, sizeof (GNUNET_HashCode));
89 for (i = 0; i < ITERATIONS; i++) 84 for (i = 0; i < ITERATIONS; i++)
90 { 85 {
91 if (0 == i % (ITERATIONS / 80)) 86 if (0 == i % (ITERATIONS / 80))
92 fprintf (stderr, "."); 87 fprintf (stderr, ".");
93 GNUNET_CRYPTO_hash (&k, sizeof (GNUNET_HashCode), &n); 88 GNUNET_CRYPTO_hash (&k, sizeof (GNUNET_HashCode), &n);
94 ASSERT (GNUNET_OK == GNUNET_DATACACHE_put (h, 89 ASSERT (GNUNET_OK == GNUNET_DATACACHE_put (h,
95 &k, 90 &k,
96 sizeof (GNUNET_HashCode), 91 sizeof (GNUNET_HashCode),
97 (const char *) &n, 92 (const char *) &n,
98 1+i%16, 93 1 + i % 16, exp));
99 exp)); 94 k = n;
100 k = n; 95 }
101 }
102 fprintf (stderr, "\n"); 96 fprintf (stderr, "\n");
103 fprintf (stdout, "Stored %u items in %llums\n", 97 fprintf (stdout, "Stored %u items in %llums\n",
104 ITERATIONS, 98 ITERATIONS,
105 (unsigned long long) GNUNET_TIME_absolute_get_duration(start).rel_value); 99 (unsigned long long)
106 GNUNET_snprintf (gstr, sizeof (gstr), 100 GNUNET_TIME_absolute_get_duration (start).rel_value);
107 "DATACACHE-%s", 101 GNUNET_snprintf (gstr, sizeof (gstr), "DATACACHE-%s", plugin_name);
108 plugin_name);
109 GAUGER (gstr, 102 GAUGER (gstr,
110 "Time to PUT item in datacache", 103 "Time to PUT item in datacache",
111 GNUNET_TIME_absolute_get_duration(start).rel_value / ITERATIONS, 104 GNUNET_TIME_absolute_get_duration (start).rel_value / ITERATIONS,
112 "ms/item"); 105 "ms/item");
113 start = GNUNET_TIME_absolute_get (); 106 start = GNUNET_TIME_absolute_get ();
114 memset (&k, 0, sizeof (GNUNET_HashCode)); 107 memset (&k, 0, sizeof (GNUNET_HashCode));
115 for (i = 0; i < ITERATIONS; i++) 108 for (i = 0; i < ITERATIONS; i++)
116 { 109 {
117 if (0 == i % (ITERATIONS / 80)) 110 if (0 == i % (ITERATIONS / 80))
118 fprintf (stderr, "."); 111 fprintf (stderr, ".");
119 GNUNET_CRYPTO_hash (&k, sizeof (GNUNET_HashCode), &n); 112 GNUNET_CRYPTO_hash (&k, sizeof (GNUNET_HashCode), &n);
120 GNUNET_DATACACHE_get (h, &k, 1+i%16, 113 GNUNET_DATACACHE_get (h, &k, 1 + i % 16, &checkIt, &n);
121 &checkIt, &n); 114 k = n;
122 k = n; 115 }
123 }
124 fprintf (stderr, "\n"); 116 fprintf (stderr, "\n");
125 fprintf (stdout, 117 fprintf (stdout,
126 "Found %u/%u items in %llums (%u were deleted during storage processing)\n", 118 "Found %u/%u items in %llums (%u were deleted during storage processing)\n",
127 found, ITERATIONS, 119 found, ITERATIONS,
128 (unsigned long long) GNUNET_TIME_absolute_get_duration(start).rel_value, 120 (unsigned long long)
129 ITERATIONS - found); 121 GNUNET_TIME_absolute_get_duration (start).rel_value,
122 ITERATIONS - found);
130 if (found > 0) 123 if (found > 0)
131 GAUGER (gstr, 124 GAUGER (gstr,
132 "Time to GET item from datacache", 125 "Time to GET item from datacache",
133 GNUNET_TIME_absolute_get_duration(start).rel_value / found, "ms/item"); 126 GNUNET_TIME_absolute_get_duration (start).rel_value / found,
127 "ms/item");
134 GNUNET_DATACACHE_destroy (h); 128 GNUNET_DATACACHE_destroy (h);
135 ASSERT (ok == 0); 129 ASSERT (ok == 0);
136 return; 130 return;
@@ -146,7 +140,8 @@ main (int argc, char *argv[])
146{ 140{
147 char *pos; 141 char *pos;
148 char cfg_name[128]; 142 char cfg_name[128];
149 char *const xargv[] = { 143
144 char *const xargv[] = {
150 "perf-datacache", 145 "perf-datacache",
151 "-c", 146 "-c",
152 cfg_name, 147 cfg_name,
@@ -158,7 +153,7 @@ main (int argc, char *argv[])
158 struct GNUNET_GETOPT_CommandLineOption options[] = { 153 struct GNUNET_GETOPT_CommandLineOption options[] = {
159 GNUNET_GETOPT_OPTION_END 154 GNUNET_GETOPT_OPTION_END
160 }; 155 };
161 156
162 GNUNET_log_setup ("perf-datacache", 157 GNUNET_log_setup ("perf-datacache",
163#if VERBOSE 158#if VERBOSE
164 "DEBUG", 159 "DEBUG",
@@ -168,22 +163,20 @@ main (int argc, char *argv[])
168 NULL); 163 NULL);
169 /* determine name of plugin to use */ 164 /* determine name of plugin to use */
170 plugin_name = argv[0]; 165 plugin_name = argv[0];
171 while (NULL != (pos = strstr(plugin_name, "_"))) 166 while (NULL != (pos = strstr (plugin_name, "_")))
172 plugin_name = pos+1; 167 plugin_name = pos + 1;
173 if (NULL != (pos = strstr(plugin_name, "."))) 168 if (NULL != (pos = strstr (plugin_name, ".")))
174 pos[0] = 0; 169 pos[0] = 0;
175 else 170 else
176 pos = (char *) plugin_name; 171 pos = (char *) plugin_name;
177 172
178 GNUNET_snprintf (cfg_name, 173 GNUNET_snprintf (cfg_name,
179 sizeof (cfg_name), 174 sizeof (cfg_name),
180 "perf_datacache_data_%s.conf", 175 "perf_datacache_data_%s.conf", plugin_name);
181 plugin_name);
182 if (pos != plugin_name) 176 if (pos != plugin_name)
183 pos[0] = '.'; 177 pos[0] = '.';
184 GNUNET_PROGRAM_run ((sizeof (xargv) / sizeof (char *)) - 1, 178 GNUNET_PROGRAM_run ((sizeof (xargv) / sizeof (char *)) - 1,
185 xargv, "perf-datacache", "nohelp", 179 xargv, "perf-datacache", "nohelp", options, &run, NULL);
186 options, &run, NULL);
187 if (ok != 0) 180 if (ok != 0)
188 fprintf (stderr, "Missed some perfcases: %d\n", ok); 181 fprintf (stderr, "Missed some perfcases: %d\n", ok);
189 return ok; 182 return ok;