Remove test which fails on Travis due to the noisy neighbor and
inconsistent performance on Travis.
from __future__ import absolute_import
-import json
-import copy
-import string
-import random
-from timeit import default_timer as timer
-
import unittest2
from st2common.util.misc import rstrip_last_char
@@ -100,78 +94,3 @@ class MiscUtilTestCase(unittest2.TestCase):
result = fast_deepcopy(value)
self.assertEqual(result, value)
self.assertEqual(result, expected_value)
-
- def test_fast_deepcopy_is_faster_than_copy_deepcopy(self):
- def random_string(N):
- return ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(N))
-
- def random_dict(width=5, height=5, levels=2):
- dct = {}
- lst = [random_string(4) for i in range(width)]
- lst2 = [random.randint(0, 10000) for i in range(width)]
- lst3 = [bool(random.randint(0, 1)) for i in range(width)]
- for j in range(height):
- dct[str(j)] = lst
- dct[str(width + j)] = lst2
- dct[str(2 * width + j)] = lst3
-
- for i in range(levels):
- new_dct = {}
- for j in range(height):
- new_dct[str(j)] = dct
- dct = json.loads(json.dumps(new_dct))
-
- return new_dct
-
- error_msg = 'fast_deepcopy is not faster than copy.deepcopy'
-
- # 1. Smaller dict
- data = random_dict(width=10, levels=2, height=2)
-
- # fast_deepcopy
- start = timer()
- fast_deepcopy(data)
- end = timer()
- duration_1 = (end - start)
-
- # copy.deepcopy
- start = timer()
- copy.deepcopy(data)
- end = timer()
- duration_2 = (end - start)
-
- self.assertTrue(duration_1 < duration_2, error_msg)
-
- # 2. Medium sized dict
- data = random_dict(width=20, levels=3, height=4)
-
- # fast_deepcopy
- start = timer()
- fast_deepcopy(data)
- end = timer()
- duration_1 = (end - start)
-
- # copy.deepcopy
- start = timer()
- copy.deepcopy(data)
- end = timer()
- duration_2 = (end - start)
-
- self.assertTrue(duration_1 < duration_2, error_msg)
-
- # 3. Larger dict
- data = random_dict(width=30, levels=5, height=4)
-
- # fast_deepcopy
- start = timer()
- fast_deepcopy(data)
- end = timer()
- duration_1 = (end - start)
-
- # copy.deepcopy
- start = timer()
- copy.deepcopy(data)
- end = timer()
- duration_2 = (end - start)
-
- self.assertTrue(duration_1 < duration_2, error_msg)
