Example #1
0
def main():
    print "save test"

    rb = RankBlock("abc.aarank")

    base_rank = [randint(10, 100)]

    def get_ranks():
        ranks = []
        for _ in range(31):
            base_rank[0] += randint(-3, 3)
            n = base_rank[0]
            ranks.append(1000 if n > 1000 else (-n if n < 0 else n))
        return ranks

    ranks = [get_ranks(), get_ranks(), get_ranks()]

    # rb.f.seek(0, 2)
    # print 'flen', rb.f.tell()

    start = time()
    for country in xrange(160):
        for category in xrange(20):
            for feed in range(4):
                idx = rb.add_meta(country, category, feed)
                rb.set_ranks(idx, ranks[idx % 3])
    end = time()
    print "time insert: {:.2f}ms".format((end - start) * 1000)
Example #2
0
def main2():
    print "load test"
    rb = RankBlock("abc.aarank")

    for meta in rb.metas:
        if (2 <= meta.country <= 5) and 4 <= meta.category <= 6 and meta.feed == 2:
            # print meta
            print rb.get_ranks(meta.idx)