mirror of
https://github.com/valitydev/yandex-tank.git
synced 2024-11-06 10:25:17 +00:00
updated instances_schedule semantics (fix #77)
This commit is contained in:
parent
41f5b18014
commit
818646cac2
@ -36,11 +36,11 @@ class LoadPlanBuilder(object):
|
||||
if count < 0:
|
||||
raise StepperConfigurationError(
|
||||
"Can not stop instances in instances_schedule.")
|
||||
interval = float(duration) / count
|
||||
interval = float(duration) / (count - 1)
|
||||
start_time = self.duration
|
||||
self.generators.append(int(start_time + i * interval)
|
||||
for i in xrange(0, count))
|
||||
self.steps += [(self.instances + i, int(interval / 1000.0)) for i in xrange(0, count)]
|
||||
self.steps += [(self.instances + i + 1, int(interval / 1000.0)) for i in xrange(0, count)]
|
||||
self.instances += count
|
||||
self.duration += duration
|
||||
return self
|
||||
@ -51,8 +51,8 @@ class LoadPlanBuilder(object):
|
||||
return self
|
||||
|
||||
def line(self, initial_instances, final_instances, duration):
|
||||
self.start(initial_instances - self.instances)
|
||||
self.ramp(final_instances - initial_instances, duration)
|
||||
self.start(initial_instances - self.instances - 1)
|
||||
self.ramp(final_instances - initial_instances + 1, duration)
|
||||
return self
|
||||
|
||||
def stairway(self, initial_instances, final_instances, step_size, step_duration):
|
||||
@ -177,14 +177,14 @@ def create(instances_schedule):
|
||||
|
||||
>>> from util import take
|
||||
|
||||
>>> take(7, LoadPlanBuilder().ramp(5, 5000).create())
|
||||
>>> take(7, LoadPlanBuilder().ramp(5, 4000).create())
|
||||
[0, 1000, 2000, 3000, 4000, 0, 0]
|
||||
|
||||
>>> take(7, create(['ramp(5, 5s)']))
|
||||
>>> take(7, create(['ramp(5, 4s)']))
|
||||
[0, 1000, 2000, 3000, 4000, 0, 0]
|
||||
|
||||
>>> take(12, create(['ramp(5, 5s)', 'wait(5s)', 'ramp(5,5s)']))
|
||||
[0, 1000, 2000, 3000, 4000, 10000, 11000, 12000, 13000, 14000, 0, 0]
|
||||
>>> take(12, create(['ramp(5, 4s)', 'wait(5s)', 'ramp(5,4s)']))
|
||||
[0, 1000, 2000, 3000, 4000, 9000, 10000, 11000, 12000, 13000, 0, 0]
|
||||
|
||||
>>> take(7, create(['wait(5s)', 'ramp(5, 0)']))
|
||||
[5000, 5000, 5000, 5000, 5000, 0, 0]
|
||||
@ -192,17 +192,17 @@ def create(instances_schedule):
|
||||
>>> take(7, create([]))
|
||||
[0, 0, 0, 0, 0, 0, 0]
|
||||
|
||||
>>> take(12, create(['line(1, 10, 5s)']))
|
||||
[0, 555, 1111, 1666, 2222, 2777, 3333, 3888, 4444, 0, 0, 0]
|
||||
>>> take(12, create(['line(1, 9, 4s)']))
|
||||
[0, 500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 0, 0, 0]
|
||||
|
||||
>>> take(12, create(['const(3, 5s)', 'line(7, 10, 5s)']))
|
||||
[0, 0, 0, 5000, 5000, 5000, 5000, 5000, 6666, 8333, 0, 0]
|
||||
>>> take(12, create(['const(3, 5s)', 'line(7, 11, 2s)']))
|
||||
[0, 0, 0, 5000, 5000, 5000, 5000, 5500, 6000, 6500, 7000, 0]
|
||||
|
||||
>>> take(12, create(['step(2, 10, 2, 3s)']))
|
||||
[0, 0, 3000, 3000, 6000, 6000, 9000, 9000, 12000, 12000, 0, 0]
|
||||
|
||||
>>> take(12, LoadPlanBuilder().const(3, 1000).line(5, 10, 5000).steps)
|
||||
[(3, 1), (5, 1), (6, 1), (7, 1), (8, 1), (9, 1)]
|
||||
[(3, 1), (5, 1), (6, 1), (7, 1), (8, 1), (9, 1), (10, 1)]
|
||||
|
||||
>>> take(12, LoadPlanBuilder().stairway(100, 950, 100, 30000).steps)
|
||||
[(100, 30), (200, 30), (300, 30), (400, 30), (500, 30), (600, 30), (700, 30), (800, 30), (900, 30), (950, 30)]
|
||||
|
Loading…
Reference in New Issue
Block a user