<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 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)