This adds an expected= argument to Connection.connectConsumer(), which then returns a Deferred that fires when enough bytes have been written to the consumer. It also adds Connection.writeToFile(), a helper method that writes bytes to a filehandle.
This writes timeline data to a .json file, which can be examined later to find likely candidates for optimization.