Skip to content

Commit bbce3f2

Browse files
authored
docs: update readme
PR-URL: #38
1 parent f397d0a commit bbce3f2

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Diff for: readme.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ var profiler = require('v8-profiler-node8');
4646
`deleteAllSnapshots()` - works as described in name.
4747

4848
```js
49+
const profiler = require('v8-profiler-node8')
4950
var snapshot1 = profiler.takeSnapshot('1');
50-
var snapshot2 = profiler.takeSnapshot();
51+
var snapshot2 = profiler.takeSnapshot()
52+
console.log(profiler.snapshots);
5153
profiler.deleteAllSnapshots();
5254
```
5355

@@ -62,9 +64,11 @@ profiler.deleteAllSnapshots();
6264
`collectSample()` - causes all active profiles to synchronously record the current callstack. Does not add a new top level sample, only adds more detail to the call graph.
6365

6466
```js
67+
const profiler = require('v8-profiler-node8')
6568
profiler.startProfiling('', true);
6669
setTimeout(function() {
6770
var profile = profiler.stopProfiling('');
71+
console.log(profile)
6872
profiler.deleteAllProfiles();
6973
}, 1000);
7074
```
@@ -101,7 +105,7 @@ snapshot1.export(function(error, result) {
101105
// Export snapshot to file stream
102106
snapshot2.export()
103107
.pipe(fs.createWriteStream('snapshot2.json'))
104-
.on('finish', snapshot2.delete);
108+
.on('finish', snapshot2.delete.bind(snapshot2));
105109
```
106110

107111
## CPU Profile API
@@ -119,7 +123,7 @@ var profile1 = profiler.stopProfiling();
119123
profiler.startProfiling('2', true);
120124
var profile2 = profiler.stopProfiling();
121125

122-
console.log(snapshot1.getHeader(), snapshot2.getHeader());
126+
console.log(profile1.getHeader(), profile2.getHeader());
123127

124128
profile1.export(function(error, result) {
125129
fs.writeFileSync('profile1.json', result);

0 commit comments

Comments
 (0)