summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKeith Bostic <keith.bostic@mongodb.com>2016-10-03 22:36:29 -0400
committerAlex Gorrod <alexander.gorrod@mongodb.com>2016-10-04 13:36:29 +1100
commit84d5635dfc011bcae30d33b8df173cbc9f2eb7bc (patch)
tree8cf92dce70173e3c4a1dc877227e87057528155d /test
parent19445fbfdfb81cefcb4c9f2a67b0fba360aaa515 (diff)
downloadmongo-84d5635dfc011bcae30d33b8df173cbc9f2eb7bc.tar.gz
WT-2941 Improve test/format to use faster key-generation functions (#3073)
Diffstat (limited to 'test')
-rw-r--r--test/format/util.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/test/format/util.c b/test/format/util.c
index 667f6d6bcb1..a709aa93a2e 100644
--- a/test/format/util.c
+++ b/test/format/util.c
@@ -78,7 +78,7 @@ key_gen_setup(WT_ITEM *key)
}
static void
-key_gen_common(WT_ITEM *key, uint64_t keyno, int suffix)
+key_gen_common(WT_ITEM *key, uint64_t keyno, const char * const suffix)
{
int len;
char *p;
@@ -86,11 +86,15 @@ key_gen_common(WT_ITEM *key, uint64_t keyno, int suffix)
p = key->mem;
/*
- * The key always starts with a 10-digit string (the specified cnt)
+ * The key always starts with a 10-digit string (the specified row)
* followed by two digits, a random number between 1 and 15 if it's
* an insert, otherwise 00.
*/
- len = sprintf(p, "%010" PRIu64 ".%02d", keyno, suffix);
+ u64_to_string_zf(keyno, key->mem, 11);
+ p[10] = '.';
+ p[11] = suffix[0];
+ p[12] = suffix[1];
+ len = 13;
/*
* In a column-store, the key is only used for Berkeley DB inserts,
@@ -118,13 +122,19 @@ key_gen_common(WT_ITEM *key, uint64_t keyno, int suffix)
void
key_gen(WT_ITEM *key, uint64_t keyno)
{
- key_gen_common(key, keyno, 0);
+ key_gen_common(key, keyno, "00");
}
void
key_gen_insert(WT_RAND_STATE *rnd, WT_ITEM *key, uint64_t keyno)
{
- key_gen_common(key, keyno, (int)mmrand(rnd, 1, 15));
+ static const char * const suffix[15] = {
+ "01", "02", "03", "04", "05",
+ "06", "07", "08", "09", "10",
+ "11", "12", "13", "14", "15"
+ };
+
+ key_gen_common(key, keyno, suffix[mmrand(rnd, 1, 15) - 1]);
}
static uint32_t val_dup_data_len; /* Length of duplicate data items */
@@ -221,7 +231,7 @@ val_gen(WT_RAND_STATE *rnd, WT_ITEM *value, uint64_t keyno)
p[10] = '/';
value->size = val_dup_data_len;
} else {
- (void)sprintf(p, "%010" PRIu64, keyno);
+ u64_to_string_zf(keyno, p, 11);
p[10] = '/';
value->size =
value_len(rnd, keyno, g.c_value_min, g.c_value_max);