Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Unified Diff: sdk/lib/io/file_impl.dart

Issue 298353002: Add read/write stats to Socket and RandomAccessFile. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/socket_patch.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/file_impl.dart
diff --git a/sdk/lib/io/file_impl.dart b/sdk/lib/io/file_impl.dart
index c43b4cf60e9db3a5cc97ec38e8f6566b76bb02cb..cd1ad334f353a039438d3d3cf255ddfc86efd142 100644
--- a/sdk/lib/io/file_impl.dart
+++ b/sdk/lib/io/file_impl.dart
@@ -567,6 +567,11 @@ class _RandomAccessFile
bool _asyncDispatched = false;
SendPort _fileService;
+ int _totalRead = 0;
+ int _totalWritten = 0;
+ int _readCount = 0;
+ int _writeCount = 0;
+
_RandomAccessFile(this._id, this.path) {
_files[_serviceId] = this;
@@ -587,6 +592,10 @@ class _RandomAccessFile
}
r['asyncDispatched'] = _asyncDispatched;
r['fd'] = _getFD(_id);
+ r['totalRead'] = _totalRead;
+ r['totalWritten'] = _totalWritten;
+ r['readCount'] = _totalWritten;
+ r['writeCount'] = _writeCount;
return r;
}
@@ -627,6 +636,8 @@ class _RandomAccessFile
if (_isErrorResponse(response)) {
throw _exceptionFromResponse(response, "readByte failed", path);
}
+ _readCount++;
+ _totalRead++;
return response;
});
}
@@ -639,6 +650,8 @@ class _RandomAccessFile
if (result is OSError) {
throw new FileSystemException("readByte failed", path, result);
}
+ _readCount++;
+ _totalRead++;
return result;
}
@@ -650,6 +663,8 @@ class _RandomAccessFile
if (_isErrorResponse(response)) {
throw _exceptionFromResponse(response, "read failed", path);
}
+ _readCount++;
+ _totalRead += response[1].length;
return response[1];
});
}
@@ -665,6 +680,8 @@ class _RandomAccessFile
if (result is OSError) {
throw new FileSystemException("readSync failed", path, result);
}
+ _readCount++;
+ _totalRead += result.length;
return result;
}
@@ -684,6 +701,8 @@ class _RandomAccessFile
var read = response[1];
var data = response[2];
buffer.setRange(start, start + read, data);
+ _readCount++;
+ _totalRead += read;
return read;
});
}
@@ -713,6 +732,8 @@ class _RandomAccessFile
if (result is OSError) {
throw new FileSystemException("readInto failed", path, result);
}
+ _readCount++;
+ _totalRead += result;
return result;
}
@@ -724,6 +745,8 @@ class _RandomAccessFile
if (_isErrorResponse(response)) {
throw _exceptionFromResponse(response, "writeByte failed", path);
}
+ _writeCount++;
+ _totalWritten++;
return this;
});
}
@@ -739,6 +762,8 @@ class _RandomAccessFile
if (result is OSError) {
throw new FileSystemException("writeByte failed", path, result);
}
+ _writeCount++;
+ _totalWritten++;
return result;
}
@@ -765,6 +790,8 @@ class _RandomAccessFile
if (_isErrorResponse(response)) {
throw _exceptionFromResponse(response, "writeFrom failed", path);
}
+ _writeCount++;
+ _totalWritten += end - (start - result.start);
return this;
});
}
@@ -791,6 +818,8 @@ class _RandomAccessFile
if (result is OSError) {
throw new FileSystemException("writeFrom failed", path, result);
}
+ _writeCount++;
+ _totalWritten += end - (start - bufferAndStart.start);
}
Future<RandomAccessFile> writeString(String string,
« no previous file with comments | « runtime/bin/socket_patch.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698