| Index: sdk/lib/io/io_resource_info.dart
|
| diff --git a/sdk/lib/io/io_resource_info.dart b/sdk/lib/io/io_resource_info.dart
|
| index 8c30c646995627e7bead00ebca152a04ef2a87a1..31c57a2efdc55e428a8deac2e4f9343f33fbcc30 100644
|
| --- a/sdk/lib/io/io_resource_info.dart
|
| +++ b/sdk/lib/io/io_resource_info.dart
|
| @@ -31,9 +31,6 @@ abstract class _IOResourceInfo {
|
| static int getNextID() => _count++;
|
| }
|
|
|
| -// TODO(ricow): Move stopwatch into this class and use it for both files
|
| -// and sockets (by using setters on totalRead/totalWritten). Also, consider
|
| -// setting readCount and writeCount in those setters.
|
| abstract class _ReadWriteResourceInfo extends _IOResourceInfo {
|
| int totalRead;
|
| int totalWritten;
|
| @@ -42,6 +39,29 @@ abstract class _ReadWriteResourceInfo extends _IOResourceInfo {
|
| double lastRead;
|
| double lastWrite;
|
|
|
| + static final Stopwatch _sw = new Stopwatch()..start();
|
| + static double get timestamp => _sw.elapsedMicroseconds / 1000000.0;
|
| +
|
| + // Not all call sites use this. In some cases, e.g., a socket, a read does
|
| + // not always mean that we actually read some bytes (we may do a read to see
|
| + // if there are some bytes available).
|
| + void addRead(int bytes) {
|
| + totalRead += bytes;
|
| + readCount++;
|
| + lastRead = timestamp;
|
| + }
|
| +
|
| + // In cases where we read but did not neccesarily get any bytes, use this to
|
| + // update the readCount and timestamp. Manually update totalRead if any bytes
|
| + // where acutally read.
|
| + void didRead() => addRead(0);
|
| +
|
| + void addWrite(int bytes) {
|
| + totalWritten += bytes;
|
| + writeCount++;
|
| + lastWrite = timestamp;
|
| + }
|
| +
|
| _ReadWriteResourceInfo(String type) :
|
| totalRead = 0,
|
| totalWritten = 0,
|
|
|