aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2009-07-17 12:41:48 +0000
committerChristian Grothoff <christian@grothoff.org>2009-07-17 12:41:48 +0000
commit8146ad014b181ea88150d67a9780eea2103ae446 (patch)
treece1612c3bbbe1d5ed2a073772064bd4ab665fce2 /src
parent9de190ef8975f525d2e841e6658e344e771e1a19 (diff)
downloadgnunet-8146ad014b181ea88150d67a9780eea2103ae446.tar.gz
gnunet-8146ad014b181ea88150d67a9780eea2103ae446.zip
typo
Diffstat (limited to 'src')
-rw-r--r--src/datastore/perf_datastore_api.c101
1 files changed, 55 insertions, 46 deletions
diff --git a/src/datastore/perf_datastore_api.c b/src/datastore/perf_datastore_api.c
index beaafbd63..4d84d88bd 100644
--- a/src/datastore/perf_datastore_api.c
+++ b/src/datastore/perf_datastore_api.c
@@ -114,43 +114,7 @@ static int ok;
114static int 114static int
115putValue (int i, int k) 115putValue (int i, int k)
116{ 116{
117 size_t size;
118 static GNUNET_HashCode key;
119 static int ic;
120 static char data[65536];
121 117
122 /* most content is 32k */
123 size = 32 * 1024;
124 if (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 16) == 0) /* but some of it is less! */
125 size = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 32 * 1024);
126 size = size - (size & 7); /* always multiple of 8 */
127
128 GNUNET_CRYPTO_hash (&key, sizeof (GNUNET_HashCode), &key);
129 memset (data, i, size);
130 if (i > 255)
131 memset (data, i - 255, size / 2);
132 data[0] = k;
133 GNUNET_DATASTORE_put (datastore,
134 0,
135 &key,
136 size,
137 data,
138 i,
139 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100),
140 i,
141 GNUNET_TIME_relative_to_absolute
142 (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
143 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 1000))),
144 TIMEOUT,
145 NULL, NULL);
146 ic++;
147#if REPORT_ID
148 if (ic % REP_FREQ == 0)
149 fprintf (stderr, "I");
150#endif
151 stored_bytes += size;
152 stored_ops++;
153 stored_entries++;
154 return GNUNET_OK; 118 return GNUNET_OK;
155} 119}
156 120
@@ -202,29 +166,74 @@ run_continuation (void *cls,
202 166
203 167
204 168
169
170static void
171check_success (void *cls,
172 int success,
173 const char *msg)
174{
175 struct CpsRunContext *crc = cls;
176 if (GNUNET_OK != success)
177 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
178 "%s\n", msg);
179 GNUNET_assert (GNUNET_OK == success);
180 ic++;
181#if REPORT_ID
182 if (ic % REP_FREQ == 0)
183 fprintf (stderr, "I");
184#endif
185 stored_bytes += size;
186 stored_ops++;
187 stored_entries++;
188 GNUNET_SCHEDULER_add_continuation (crc->sched,
189 GNUNET_NO,
190 &run_continuation,
191 crc,
192 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
193}
194
205static void 195static void
206run_continuation (void *cls, 196run_continuation (void *cls,
207 const struct GNUNET_SCHEDULER_TaskContext *tc) 197 const struct GNUNET_SCHEDULER_TaskContext *tc)
208{ 198{
209 struct CpsRunContext *crc = cls; 199 struct CpsRunContext *crc = cls;
200 size_t size;
201 static GNUNET_HashCode key;
202 static int ic;
203 static char data[65536];
204 int i;
205 int k;
206
210 ok = (int) crc->phase; 207 ok = (int) crc->phase;
211 switch (crc->phase) 208 switch (crc->phase)
212 { 209 {
213 case RP_PUT: 210 case RP_PUT:
214 memset (&crc->key, 256 - crc->i, sizeof (GNUNET_HashCode)); 211 memset (&crc->key, 256 - crc->i, sizeof (GNUNET_HashCode));
215 212 i = crc->j;
216 GNUNET_assert (GNUNET_OK == putValue (crc->j, crc->i)); 213 k = crc->i;
214 /* most content is 32k */
215 size = 32 * 1024;
216 if (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 16) == 0) /* but some of it is less! */
217 size = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 32 * 1024);
218 size = size - (size & 7); /* always multiple of 8 */
219 GNUNET_CRYPTO_hash (&key, sizeof (GNUNET_HashCode), &key);
220 memset (data, i, size);
221 if (i > 255)
222 memset (data, i - 255, size / 2);
223 data[0] = k;
217 GNUNET_DATASTORE_put (datastore, 224 GNUNET_DATASTORE_put (datastore,
218 0, 225 0,
219 &crc->key, 226 &key,
220 get_size (crc->i), 227 size,
221 get_data (crc->i), 228 data,
222 get_type (crc->i), 229 i,
223 get_priority (crc->i), 230 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100),
224 get_anonymity (crc->i), 231 i,
225 get_expiration (crc->i), 232 GNUNET_TIME_relative_to_absolute
233 (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
234 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 1000))),
226 TIMEOUT, 235 TIMEOUT,
227 &check_success, 236 &check_success,
228 crc); 237 crc);
229 crc->j++; 238 crc->j++;
230 if (crc->j < PUT_10) 239 if (crc->j < PUT_10)