Add a way where you can tell the loadfile to add to the previous value of a
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Wed, 13 Jan 2010 03:53:07 +0000 (14:53 +1100)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Wed, 13 Jan 2010 03:53:07 +0000 (14:53 +1100)
parameter in the loeadfile.
This is useful for loadfiles where one might want to perform sequential read/writes

The syntax in the loadfile is "+value"   which will be replaced by the previous plus value

See loadfile/smb_2.txt for an example

child.c
loadfiles/smb_2.txt [new file with mode: 0644]

diff --git a/child.c b/child.c
index acfa5d027bd5ff4f3afafa9c7dcdf3f11941dcd8..e409a68f9e8d8e74e87306b492e993519ffbb2a0 100644 (file)
--- a/child.c
+++ b/child.c
@@ -103,13 +103,24 @@ static void finish_op(struct child_struct *child, struct op *op)
  * '*%1024'  : random number between 0 and 1023
  * '* /1024'  : random 64 bit number aligned to n*1024
  * '*%1024/2 : random even number between 0 and 1023
+ *
+ *
+ * a special case is when the format starts with a '+' and is followed by
+ * a number, in which case we reuse the number from the previous line in the
+ * loadfile and add <number> to it :
+ * '+1024' : add 1024 to the value from the previous line in the loadfile
  */
-uint64_t parse_special(const char *fmt)
+static uint64_t parse_special(const char *fmt, uint64_t prev_val)
 {
        char q;
        uint64_t num;
        uint64_t val;
 
+       if (*fmt == '+') {
+               val = strtoll(fmt+1, NULL, 0);
+               return prev_val + val;
+       }
+
        num = random();
        num = (num <<32) | random();
 
@@ -160,6 +171,7 @@ static void child_op(struct child_struct *child, const char *opname,
                     const char *fname, const char *fname2, 
                     char **params, const char *status)
 {
+       static struct dbench_op prev_op;
        struct dbench_op op;
        unsigned i;
 
@@ -172,13 +184,18 @@ static void child_op(struct child_struct *child, const char *opname,
        op.fname2 = fname2;
        op.status = status;
        for (i=0;i<sizeof(op.params)/sizeof(op.params[0]);i++) {
-               if (params[i][0] == '*') {
-                       op.params[i] = parse_special(params[i]);
-               } else {
+               switch (params[i][0]) {
+               case '*':
+               case '+':
+                       op.params[i] = parse_special(params[i], prev_op.params[i]);
+                       break;
+               default:
                        op.params[i] = params[i]?ival(params[i]):0;
                }
        }
 
+       prev_op = op;
+
        if (strcasecmp(op.op, "Sleep") == 0) {
                nb_sleep(op.params[0]);
                return;
diff --git a/loadfiles/smb_2.txt b/loadfiles/smb_2.txt
new file mode 100644 (file)
index 0000000..1b1ae78
--- /dev/null
@@ -0,0 +1,11 @@
+# example loadfile for SMB
+# create a file and write 40k to it at sequentially, 4kb at a time
+# make sure the offset is between 0 and 0x10000000 and that it is aligned to 4kb
+# boundaries
+#
+#MKDIR "/client1" *
+OPEN "/client1/test.txt" 0x0c SUCCESS
+WRITE "/client1/test.txt" 0 4096 SUCCESS
+REPEAT 9
+WRITE "/client1/test.txt" +4096 4096 SUCCESS
+CLOSE "/client1/test.txt" SUCCESS