-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from RaisinTen/move-example-under-docs
Move example under docs
- Loading branch information
Showing
7 changed files
with
50 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
.github | ||
events.json | ||
example-perfetto.png | ||
example.js | ||
examples | ||
test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
events.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Tracing async operations | ||
|
||
A new `TraceEvents` object is created in: | ||
|
||
https://github.com/RaisinTen/perftrace/blob/e9df1f8c4488a69c9051e8a62f0896ca7af677a6/docs/examples/tracing-async-operations/index.js#L6 | ||
|
||
Before the process exits, the `TraceEvents` object is destroyed and the trace events are stringified and printed to `events.json` in: | ||
|
||
https://github.com/RaisinTen/perftrace/blob/e9df1f8c4488a69c9051e8a62f0896ca7af677a6/docs/examples/tracing-async-operations/index.js#L8-L12 | ||
|
||
The code that needs to be profiled can be done using the `peformance.measure()` and `peformance.mark()` APIs from [Node.js](https://nodejs.org/api/perf_hooks.html#performancemarkname-options) and the [Web](https://www.w3.org/TR/user-timing): | ||
|
||
```js | ||
peformance.mark("before"); | ||
// code that needs to be profiled | ||
performance.measure("after", "before"); | ||
``` | ||
|
||
like it's being done in: | ||
|
||
https://github.com/RaisinTen/perftrace/blob/e9df1f8c4488a69c9051e8a62f0896ca7af677a6/docs/examples/tracing-async-operations/index.js#L14-L26 | ||
|
||
After running `node .`, the generated `events.json` file can be opened on [https://ui.perfetto.dev](https://ui.perfetto.dev) for visualization: | ||
|
||
![](./perfetto.png) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "tracing-async-operations", | ||
"version": "1.0.0", | ||
"private": true, | ||
"description": "Tracing async operations", | ||
"main": "index.js", | ||
"author": "Darshan Sen", | ||
"license": "MIT" | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.