def run_workload(database, keys, parameters):
    """Runs workload against the database."""
    total_weight = 0.0
    weights = []
    operations = []
    latencies_ms = {}
    for operation in OPERATIONS:
        weight = float(parameters[operation])
        if weight <= 0.0:
            continue
        total_weight += weight
        op_code = operation.split('proportion')[0]
        operations.append(op_code)
        weights.append(total_weight)
        latencies_ms[op_code] = []

    threads = []
    start = timeit.default_timer()
    for i in range(int(parameters['num_worker'])):
        thread = WorkloadThread(database, keys, parameters, total_weight,
                                weights, operations)
        thread.start()
        threads.append(thread)

    for thread in threads:
        thread.join()
        end = timeit.default_timer()

    for thread in threads:
        thread_latencies_ms = thread.latencies_ms()
        for key in latencies_ms.keys():
            latencies_ms[key].extend(thread_latencies_ms[key])

    aggregate_metrics(latencies_ms, (end - start) * 1000.0,
                      parameters['num_bucket'])
Runs workload against the database.