示例#1
0
文件: vtil_test.py 项目: vsekhar/vtil
 def test_extsorted_stress(self):
     file_size = 2 ** 20 # 1 MB
     file_count = 2.5
     typical_size = sys.getsizeof(1, random.random())
     count = int((file_size * file_count)) / typical_size
     data = ((i, random.random()) for i in xrange(count))
     sorted_data = list(extsorted(data, key=itemgetter(1), reverse=True, max_mem=file_size))
     self.assertEqual(len(sorted_data), count)
     self.assertTrue(is_sorted(sorted_data, key=itemgetter(1), reverse=True, expected_len=None))
示例#2
0
文件: vtil_test.py 项目: vsekhar/vtil
 def test_extsorted_all_at_once(self):
     data = list(random.random() for _ in xrange(10))
     max_mem = sys.getsizeof(data) * 2 # definitely big enough for whole list
     self.assertTrue(is_sorted(extsorted(data, max_mem=max_mem)))
示例#3
0
文件: vtil_test.py 项目: vsekhar/vtil
 def test_extsorted_small(self):
     data = list(random.random() for _ in xrange(10))
     max_mem = sys.getsizeof(0) - 1 # too small for even one value
     self.assertTrue(is_sorted(extsorted(data, max_mem=max_mem)))