def populate(): for i in range(1, 10000): obj = {} obj['user'] = i % 200 obj['msg'] = make_string(100) _id = db.long.insert(obj) user_2_msg[i % 200].append(_id)
def read_it_str(): # I know this string exists in the DB. giant_l = ["RGOSECGLXZHOSZRTNUYOLFGETJIGMYWKJJSGTKHJFTJNPOFKESAEMKELHXYXUXLMRBQWKQUANATQXKINKXMYKFAAIBTXVLDYJDO"] for i in range(1, 100000): giant_l.append(make_string(100)) print "reading on strings" with timer(): results = do_read_str(giant_l[0:1]) with timer(): results = do_read_str(giant_l[0:10]) with timer(): results = do_read_str(giant_l[0:100]) with timer(): results = do_read_str(giant_l[0:1000]) with timer(): results = do_read_str(giant_l[0:10000]) with timer(): results = do_read_str(giant_l[0:100000])
def test_make_string_with_nums_unsorted(self): self.assertEqual("11 33 22", main.make_string([11, 33, 22]))
def test_make_string_with_nums(self): self.assertEqual("1 2 3", main.make_string([1, 2, 3]))
def test_make_string_empty(self): self.assertEqual("", main.make_string([]))