Chrome Timeline Logger
This logger helps generates a timeline JSON file that's compatible with the Chrome Dev Tools timeline viewer
Installation
npm install chrome-timeline-logger
Usage
var timeline = require('chrome-timeline-logger');
var builder = new timeline.TimelineBuilder();
var programEvent = builder.startEvent("Program");
for (index = _i = 0; _i < 10; index = ++_i) {
var event = builder.startEvent("TimeStamp", {message: "hi mum " + index + "!"});
event.usedHeapSize = process.memoryUsage().heapUsed;
event.counters = { documents: index }
console.log("some work load");
builder.endEvent();
}
builder.endEvent();
var logger = new timeline.TimelineLogger();
logger.save("./test.json", programEvent);
- Best way to discover supported events and their data is to make a recording in the timeline tool and examine it's output ;)
- I've also made an attempt to list them here TimelineRecordTypes
Above Example Output
API
######TimelineLogger
name | type | args | description |
---|
save() | method | string filepath, timelineRecordList[], onComplete() | saves an array of timeline records to a file specified by the filepath |
saveSync() | method | string filepath, timelineRecordList[] | Synchronous version of save |
version | string | | Appears at the top of each saved timeline json file |
######TimelineBuilder | | | |
name | type | args | description |
---|
startEvent() | method | string type, [object data] | starts a timeline event. Types are defined in TimelineRecordTypes |
endEvent() | method | none | ends the currently started timeline event. |
######TimelineRecord
name | type | args | description |
---|
start() | method | none | sets startTime to Date.now() |
end() | method | none | sets endTime to Date.now() |
startTime | number | | |
endTime | number | | |
children | TimelineRecord[] | | |
data | object | | |
frameId | number | | |
usedHeapSize | number | | |
usedHeapSizeDelta | number | | |
counters | object | | |
stackTrace | object | | |
History
You can discover the history inside the History.md
file
Contributing
You can discover the contributing instructions inside the Contributing.md
file
License
Licensed under the incredibly permissive MIT License
Copyright © 2013+ Stringz Solutions Ltd
Copyright © 2013+ Peter Flannery