Created
May 21, 2014 22:54
-
-
Save marcoemorais/860fd72d224fc4037a22 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/rally/benchmark/scenarios/utils.py b/rally/benchmark/scenarios/utils.py | |
index 4825795..4063fe3 100644 | |
--- a/rally/benchmark/scenarios/utils.py | |
+++ b/rally/benchmark/scenarios/utils.py | |
@@ -144,7 +144,7 @@ def atomic_action_timer(name): | |
return wrap | |
-class AtomicAction(object): | |
+class AtomicAction(utils.Timer): | |
"""A class to measure the duration of atomic operations | |
This would simplify the way measure atomic opeation duration | |
@@ -161,12 +161,10 @@ class AtomicAction(object): | |
:param scenario_instance: instance of subclass of base scenario | |
:param name: name of the ActionBuilder | |
""" | |
+ super(AtomicAction, self).__init__() | |
self.scenario_instance = scenario_instance | |
self.name = name | |
- def __enter__(self): | |
- self.start = time.time() | |
- | |
- def __exit__(self, type, value, traceback): | |
- duration = time.time() - self.start | |
- self.scenario_instance._add_atomic_actions(self.name, duration) | |
+ def __exit__(self, type, value, tb): | |
+ super(AtomicAction, self).__exit__(type, value, tb) | |
+ self.scenario_instance._add_atomic_actions(self.name, self.duration()) | |
diff --git a/tests/benchmark/scenarios/test_utils.py b/tests/benchmark/scenarios/test_utils.py | |
index b4188a3..11be52a 100644 | |
--- a/tests/benchmark/scenarios/test_utils.py | |
+++ b/tests/benchmark/scenarios/test_utils.py | |
@@ -200,7 +200,7 @@ class AtomicActionTestCase(test.TestCase): | |
self.assertEqual(c.scenario_instance, fake_scenario_instance) | |
self.assertEqual(c.name, 'asdf') | |
- @mock.patch('rally.benchmark.scenarios.utils.time') | |
+ @mock.patch('rally.utils.time') | |
def test__exit__(self, mock_time): | |
fake_scenario_instance = mock.Mock() | |
self.start = mock_time.time() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment