From aad7cdc36441b91b517006a34bbd034bc15d2af4 Mon Sep 17 00:00:00 2001 From: ning_zhang Date: Fri, 3 Aug 2012 11:47:28 -0700 Subject: [PATCH] To simulate the real workloads, the objects to be uploaded could be created in the random sizes, which are bounded (lower_object_size and upper_object_size) by the user inputs. Change-Id: I64647c5d613a0794f0807886a4833cd5c31c0c5e --- bin/swift-bench | 2 ++ swift/common/bench.py | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/bin/swift-bench b/bin/swift-bench index 120f2a5a54..df0e404f68 100755 --- a/bin/swift-bench +++ b/bin/swift-bench @@ -35,6 +35,8 @@ CONF_DEFAULTS = { 'del_concurrency': '10', 'concurrency': '', 'object_size': '1', + 'lower_object_size': '10', + 'upper_object_size': '10', 'num_objects': '1000', 'num_gets': '10000', 'delete': 'yes', diff --git a/swift/common/bench.py b/swift/common/bench.py index 097b6fd54c..6a0af88237 100644 --- a/swift/common/bench.py +++ b/swift/common/bench.py @@ -66,6 +66,8 @@ class Bench(object): self.object_size = int(conf.object_size) self.object_sources = conf.object_sources + self.lower_object_size = int(conf.lower_object_size) + self.upper_object_size = int(conf.upper_object_size) self.files = [] if self.object_sources: self.object_sources = self.object_sources.split() @@ -228,6 +230,9 @@ class BenchPUT(Bench): name = uuid.uuid4().hex if self.object_sources: source = random.choice(self.files) + elif self.upper_object_size > self.lower_object_size: + source = '0' * random.randint(self.lower_object_size, + self.upper_object_size) else: source = '0' * self.object_size device = random.choice(self.devices)