예제 #1
0
def credis_bench():
    credis_pool = ResourcePool(10, Connection, host=HOST, port=PORT)
    credis_connection.execute("flushdb")
    start = time.time()
    for x in range(NUM_INSERTS):
        with credis_pool.ctx() as conn:
            conn.execute("hset", "words", "word|{}".format(x), "1")
    print('CRedis HSET Done. Duration=', time.time() - start)
    hset_dict['credis'] = time.time() - start

    start = time.time()
    for x in range(NUM_INSERTS):
        with credis_pool.ctx() as conn:
            conn.execute("hget", "words", "word|{}".format(x))
    print('CRedis HGET Done. Duration=', time.time() - start)
    hget_dict['credis'] = time.time() - start