Beispiel #1
0
def produce(table: str):
    tnt_connection = Connection("127.0.0.1", 3302)
    trace(table, "Produce start")
    start = time.perf_counter_ns()
    for row in range(0, 100000, 1):
        next_id = tnt_connection.call("box.sequence.test_seq:next")
        tnt_connection.insert(table, (str(uuid.uuid1()), next_id[0], "TestBook_" + str(row), randint(1900, 2000)))
        if row % 1000 == 0:
            trace(table, "Done insert row: {}".format(row))
    end = time.perf_counter_ns()
    table_size = tnt_connection.call("box.space.{}:len".format(table))
    diff = (end - start) / 1000.0
    trace(table, "Completed, table size: {}, time spent: {}"
          .format(table_size[0], diff))
    return diff
Beispiel #2
0
def get_ids(tnt_connection: Connection, table: str, count: int):
    trace(table, "Get ids")
    table_size = tnt_connection.call("box.space.{}:len".format(table))
    offset = randint(0, table_size[0] - count)
    trace(table, "Get ids, table size: {}, offset: {}".format(table_size[0], offset))
    result = tnt_connection.select(space_name=table, offset=offset, limit=count)
    ids_data = [] * len(result)
    for item in result:
        ids_data.append(item[0])
    return ids_data