Skip to content

Commit

Permalink
#40: Add a Note for Benchmarks' Profiles in README (#33)
Browse files Browse the repository at this point in the history
* feat(docs): add a note for benchmarks' profiles in `README`

Signed-off-by: Tarek <[email protected]>

* feat(docs): add a note about cargo flamegraph on macos limitations

Signed-off-by: Tarek <[email protected]>

---------

Signed-off-by: Tarek <[email protected]>
  • Loading branch information
tareknaser authored May 11, 2024
1 parent 028291e commit c87108b
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,29 @@ Our benchmark suite includes tests on local files and directories. These benchma
You have the flexibility to benchmark specific files or folders by modifying the variables within the benchmark files. By default, the benchmarks operate on the [`test-assets/`](test-assets/) directory and its contents. You can change the directory/files by setting the `DIR_PATH` and `FILE_PATHS` variables to the desired values.

For pre-benchmark assessment of required time to index a huge local folder, you can modify `test_build_resource_index` test case in `src/index.rs`.

### Generating Profiles for Benchmarks

[flamegraph](https://github.com/flamegraph-rs/flamegraph) is a Cargo command that uses perf/DTrace to profile your code and then displays the results in a flame graph. It works on Linux and all platforms that support DTrace (macOS, FreeBSD, NetBSD, and possibly Windows).

To install `flamegraph`, run:

```bash
cargo install flamegraph
```

To generate a flame graph for `index_build_benchmark`, use the following command:

```bash
cargo flamegraph --bench index_build_benchmark -o index_build_benchmark.svg -- --bench
```

> [!NOTE]
> Running `cargo flamegraph` on macOS requires `DTrace`. MacOS System Integrity Protection (`SIP`) is enabled by default, which restricts most uses of `dtrace`.
>
> To work around this issue, you have two options:
>
> - Boot into recovery mode and disable some SIP protections.
> - Run as superuser to enable DTrace. This can be achieved by using `cargo flamegraph --root ...`.
>
> For further details, please refer to https://github.com/flamegraph-rs/flamegraph?tab=readme-ov-file#dtrace-on-macos

0 comments on commit c87108b

Please sign in to comment.