def do_operation(database, keys, table, operation, latencies_ms):
    """Does a single operation and records latency."""
    key = random.choice(keys)
    start = timeit.default_timer()
    if operation == 'read':
        read(database, table, key)
    elif operation == 'update':
        update(database, table,  key)
    else:
        raise ValueError('Unknown operation: %s' % operation)
    end = timeit.default_timer()
    latencies_ms[operation].append((end - start) * 1000)
Does a single operation and records latency.