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

Unified Diff: tools/logreader.js

Issue 574015: Profiler tick processor: exploit d8's readline to avoid reading (Closed)
Patch Set: Re-upload Created 10 years, 10 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 | « tools/linux-tick-processor ('k') | tools/tickprocessor.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/logreader.js
diff --git a/tools/logreader.js b/tools/logreader.js
index 20a1f54444b70c0ae3993f1cf355cc407afad602..b2aca73d218e4cf03be71b2937bbb37f3a6308b9 100644
--- a/tools/logreader.js
+++ b/tools/logreader.js
@@ -76,6 +76,18 @@ devtools.profiler.LogReader = function(dispatchTable) {
* @type {Array.<string>}
*/
this.backRefs_ = [];
+
+ /**
+ * Current line.
+ * @type {number}
+ */
+ this.lineNum_ = 0;
+
+ /**
+ * CSV lines parser.
+ * @type {devtools.profiler.CsvParser}
+ */
+ this.csvParser_ = new devtools.profiler.CsvParser();
};
@@ -136,6 +148,16 @@ devtools.profiler.LogReader.prototype.processLogChunk = function(chunk) {
/**
+ * Processes a line of V8 profiler event log.
+ *
+ * @param {string} line A line of log.
+ */
+devtools.profiler.LogReader.prototype.processLogLine = function(line) {
+ this.processLog_([line]);
+};
+
+
+/**
* Processes stack record.
*
* @param {number} pc Program counter.
@@ -280,25 +302,20 @@ devtools.profiler.LogReader.prototype.processAlias_ = function(
* @private
*/
devtools.profiler.LogReader.prototype.processLog_ = function(lines) {
- var csvParser = new devtools.profiler.CsvParser();
- try {
- for (var i = 0, n = lines.length; i < n; ++i) {
- var line = lines[i];
- if (!line) {
- continue;
- }
+ for (var i = 0, n = lines.length; i < n; ++i, ++this.lineNum_) {
+ var line = lines[i];
+ if (!line) {
+ continue;
+ }
+ try {
if (line.charAt(0) == '#' ||
line.substr(0, line.indexOf(',')) in this.backRefsCommands_) {
line = this.expandBackRef_(line);
}
- var fields = csvParser.parseLine(line);
+ var fields = this.csvParser_.parseLine(line);
this.dispatchLogRow_(fields);
- }
- } catch (e) {
- // An error on the last line is acceptable since log file can be truncated.
- if (i < n - 1) {
- this.printError('line ' + (i + 1) + ': ' + (e.message || e));
- throw e;
+ } catch (e) {
+ this.printError('line ' + (this.lineNum_ + 1) + ': ' + (e.message || e));
}
}
};
« no previous file with comments | « tools/linux-tick-processor ('k') | tools/tickprocessor.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698