Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
kateinoigakukun committed Dec 8, 2024
1 parent c1f5d18 commit c8ca25c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const wmprof = WMProf.get(instance);
wmprof.downloadSnapshot();
// Or get the pprof profile bytes (Uint8Array)
const pprof = wmprof.snapshot();
fs.writeFileSync(`wmprof-${Date.now()}.pb`, pprof);

// Get all installed profilers
const profilers = WMProf.installed();
Expand Down Expand Up @@ -71,3 +72,32 @@ You can upload the pprof profile file to the speedscope website to visualize the
- `aligned_alloc`

Otherwise, the profiler will not be able to intercept memory allocation and deallocation calls.


## Advanced Usage

### Demangle language-specific function names

We currently provide only a Swift demangler, but you can implement your own demangler for other languages.

```js
import { WMProf } from "wasm-memprof";
import { SwiftDemangler } from "wasm-memprof/plugins/swift-demangler.js";

const swiftDemangler = SwiftDemangler.create();
const WebAssembly = WMProf.wrap(globalThis.WebAssembly, {
demangler: swiftDemangler.demangle.bind(swiftDemangler),
});
```

### Capture all allocations without sampling

By default, the profiler samples memory allocations to reduce the overhead. If you want to capture all allocations, you can set the `sampleRate` option to `1`, which means the profiler traces every memory allocation.

```js
import { WMProf } from "wasm-memprof";

const WebAssembly = WMProf.wrap(globalThis.WebAssembly, {
sampleRate: 1,
});
```
Binary file modified docs/demo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c8ca25c

Please sign in to comment.