| OLD | NEW |
| 1 /* | 1 /* |
| 2 * replay_driver.c | 2 * replay_driver.c |
| 3 * | 3 * |
| 4 * A driver for the replay_database implementation | 4 * A driver for the replay_database implementation |
| 5 * | 5 * |
| 6 * David A. McGrew | 6 * David A. McGrew |
| 7 * Cisco Systems, Inc. | 7 * Cisco Systems, Inc. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 /* | 10 /* |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 #include <time.h> /* for clock() */ | 226 #include <time.h> /* for clock() */ |
| 227 #include <stdlib.h> /* for random() */ | 227 #include <stdlib.h> /* for random() */ |
| 228 | 228 |
| 229 #define REPLAY_NUM_TRIALS 10000000 | 229 #define REPLAY_NUM_TRIALS 10000000 |
| 230 | 230 |
| 231 double | 231 double |
| 232 rdb_check_adds_per_second(void) { | 232 rdb_check_adds_per_second(void) { |
| 233 uint32_t i; | 233 uint32_t i; |
| 234 rdb_t rdb; | 234 rdb_t rdb; |
| 235 clock_t timer; | 235 clock_t timer; |
| 236 int failures; /* count number of failures */ | 236 int failures = 0; /* count number of failures */ |
| 237 | 237 |
| 238 if (rdb_init(&rdb) != err_status_ok) { | 238 if (rdb_init(&rdb) != err_status_ok) { |
| 239 printf("rdb_init failed\n"); | 239 printf("rdb_init failed\n"); |
| 240 exit(1); | 240 exit(1); |
| 241 } | 241 } |
| 242 | 242 |
| 243 timer = clock(); | 243 timer = clock(); |
| 244 for(i=0; i < REPLAY_NUM_TRIALS; i+=3) { | 244 for(i=0; i < REPLAY_NUM_TRIALS; i+=3) { |
| 245 if (rdb_check(&rdb, i+2) != err_status_ok) | 245 if (rdb_check(&rdb, i+2) != err_status_ok) |
| 246 ++failures; | 246 ++failures; |
| 247 if (rdb_add_index(&rdb, i+2) != err_status_ok) | 247 if (rdb_add_index(&rdb, i+2) != err_status_ok) |
| 248 ++failures; | 248 ++failures; |
| 249 if (rdb_check(&rdb, i+1) != err_status_ok) | 249 if (rdb_check(&rdb, i+1) != err_status_ok) |
| 250 ++failures; | 250 ++failures; |
| 251 if (rdb_add_index(&rdb, i+1) != err_status_ok) | 251 if (rdb_add_index(&rdb, i+1) != err_status_ok) |
| 252 ++failures; | 252 ++failures; |
| 253 if (rdb_check(&rdb, i) != err_status_ok) | 253 if (rdb_check(&rdb, i) != err_status_ok) |
| 254 ++failures; | 254 ++failures; |
| 255 if (rdb_add_index(&rdb, i) != err_status_ok) | 255 if (rdb_add_index(&rdb, i) != err_status_ok) |
| 256 ++failures; | 256 ++failures; |
| 257 } | 257 } |
| 258 timer = clock() - timer; | 258 timer = clock() - timer; |
| 259 | 259 |
| 260 return (double) CLOCKS_PER_SEC * REPLAY_NUM_TRIALS / timer; | 260 return (double) CLOCKS_PER_SEC * REPLAY_NUM_TRIALS / timer; |
| 261 } | 261 } |
| OLD | NEW |