examples/multi_threaded_inserts.py
def run_benchmark():
    """ Run a set of InsertWorkers and record their performance. """

    stopping = threading.Event()
    workers = [ InsertWorker(stopping) for _ in range(NUM_WORKERS) ]

    print('Launching %d workers' % NUM_WORKERS)

    [ worker.start() for worker in workers ]
    time.sleep(WORKLOAD_TIME)

    print('Stopping workload')

    stopping.set()
    [ worker.join() for worker in workers ]

    with get_connection() as conn:
        count = conn.get("SELECT COUNT(*) AS count FROM %s" % TABLE).count

    print("%d rows inserted using %d workers" % (count, NUM_WORKERS))
    print("%.1f rows per second" % (count / float(WORKLOAD_TIME)))
def run_benchmark():
    """ Run a set of InsertWorkers and record their performance. """

    stopping = threading.Event()
    workers = [ InsertWorker(stopping) for _ in range(NUM_WORKERS) ]

    print('Launching %d workers' % NUM_WORKERS)

    [ worker.start() for worker in workers ]
    time.sleep(WORKLOAD_TIME)

    print('Stopping workload')

    stopping.set()
    [ worker.join() for worker in workers ]

    with get_connection() as conn:
        count = conn.get("SELECT COUNT(*) AS count FROM %s" % TABLE).count

    print("%d rows inserted using %d workers" % (count, NUM_WORKERS))
    print("%.1f rows per second" % (count / float(WORKLOAD_TIME)))
Run a set of InsertWorkers and record their performance.