Skip to content

Commit bbcdf05

Browse files
authored
chore(docs): enhance README with settings explanation (#18)
1 parent c5e23a4 commit bbcdf05

File tree

2 files changed

+42
-5
lines changed

2 files changed

+42
-5
lines changed

README.md

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@
22
[![Release](https://github.com/ntrotner/js-heap-comparator/actions/workflows/release.yml/badge.svg)](https://github.com/ntrotner/js-heap-comparator/actions/workflows/release.yml)
33
[![version](https://img.shields.io/npm/v/js-heap-comparator.svg?style=flat-square)](https://www.npmjs.com/package/js-heap-comparator)
44

5-
> Compare JS heaps from runtimes like V8
5+
<p align="center">
6+
<img src="/docs/assets/i-guess-we-doin-different-runtimes-now.png" alt="Factory worker questioning why someone would compare heaps from different runtimes" width="350">
7+
</p>
68

9+
> Compare JS heaps from engines like V8, where the heaps are sourced from different runtimes.
10+
11+
Compatible with heap outputs from Chrome Developer Tools and parsing techniques from [Memlab](https://facebook.github.io/memlab/)
712

813
## Install
914

@@ -17,12 +22,43 @@ yarn add js-heap-comparator --dev
1722

1823
## Usage
1924

25+
Check out [examples/compare-heaps.js](examples/compare-heaps.js) for a quick-start.
26+
2027
It's recommended to use the `--max-old-space-size=8192` flag when running the script to avoid memory issues, especially when multiple threads are used.
28+
29+
### Option: `presenterFilePath`
2130
Outputs are saved in the `presenterFilePath` directory. Any returns from the compare function are not planned due to the excessive use of memory.
22-
- $presenterFilePath/statistics.json: Contains the statistics of the comparison, e.g. the number of objects, the number of objects that are the same, the number of objects that are different, etc.
23-
- $presenterFilePath/perfect-match.json: Contains the objects that are the same in both heap files.
24-
- $presenterFilePath/next-best-match.json: Contains the objects that are similar in both heap files.
25-
- $presenterFilePath/disjunct-nodes.json: Contains the objects that are different in both heap files.
31+
- `$presenterFilePath/statistics.json`: Contains the statistics of the comparison, e.g. the number of objects, the number of objects that are the same, the number of objects that are different, etc.
32+
- `$presenterFilePath/perfect-match.json`: Contains the objects that are the same in both heap files.
33+
- `$presenterFilePath/next-best-match.json`: Contains the objects that are similar in both heap files.
34+
- `$presenterFilePath/disjunct-nodes.json`: Contains the objects that are different in both heap files.
35+
36+
### Option: `activePresenter`
37+
Toggles the type of presenter to output. The least memory intensive is `statistics`, as only the metadata is saved.
38+
The presenter `disjunctNodes` outputs all nodes that couldn't be matches with one another.
39+
Presenters `perfectMatch` and `nextBestMatch` are bound to change to output matches in an efficient way.
40+
41+
```javascript
42+
activePresenter: {
43+
statistics: true,
44+
perfectMatch: false,
45+
nextBestMatch: false,
46+
disjunctNodes: false,
47+
}
48+
```
49+
50+
### Option: `nextBestMatchObjectThreshold`
51+
Input value between `0.0` and `1.0`. Defines threshold for next best match algorithm, which ranks the similarity of serializable objects.
52+
It's recommended to stay above `0.5` for large heaps.
53+
54+
### Option: `nextBestMatchObjectPropertyThreshold`
55+
Input value between `1` and `Infinity`. Defines the amount of properties to compare in the next best match algorithm.
56+
This allows for optimized comparison times, as serialized objects can be deeply nested and cause unnecessary long execution times.
57+
For larger disjunct sets it's recommended to set it between `2500` and `5000`.
58+
59+
### Option: `threads`
60+
Input value `>= 1`. Used to parallelize next best match algorithm. Adds large memory overhead due to inter-process communication.
61+
It's recommended to keep it low between `1` and `4`.
2662

2763

2864
```javascript
@@ -38,6 +74,7 @@ heapComparator.initialize({
3874
},
3975
presenterFilePath: '/path/to/output/results',
4076
nextBestMatchObjectThreshold: 0.7,
77+
nextBestMatchObjectPropertyThreshold: 10000,
4178
threads: 1
4279
});
4380
heapComparator.compare('current_heapfile.json', 'next_heapfile.json');
82.3 KB
Loading

0 commit comments

Comments
 (0)