Add StreamSummary to generate summary statistics and capture failures.

This is equivalent the to behaviour in the TestResult class, but split into a
dedicated helper (so that decorators and the like don't need to waste cycles
generating them).