-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fbdd462
commit 35fc75a
Showing
3 changed files
with
38 additions
and
71 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
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,20 +1,25 @@ | ||
### Benchmark | ||
This benchmark report contains overall running time analysis of Link-Cut trees in comparison to its brute-force counterpart (MBP 14" 16Gb). | ||
This benchmark report contains overall running time analysis of Link-Cut trees in comparison to its brute-force counterpart (iMac 24", M1, 2021, 16Gb). | ||
Each test performs a number of random operations (`link(v, w)`, `cut(v, w)`, `connected(v, w)` or `findmax(v, w)`) on forests of varying sizes. | ||
|
||
| # Nodes | # Operations | Random seed | [lctree](https://github.com/azizkayumov/lctree/blob/main/src/lctree.rs) | [brute-force](https://github.com/azizkayumov/lctree/blob/main/tests/test_random.rs) | | ||
| :--- | :--- | :--- | :--- | :--- | | ||
| 100 | 10K | 564315935137013477 | 6.567967ms | 53.48109ms | | ||
| 100 | 100K | 5233351911053448040 | 44.379304ms | 321.900746ms | | ||
| 100 | 1M | 10905789823848117209 | 476.117191ms | 3.915883695s | | ||
| 500 | 2M | 5863263585868731364 | 984.139022ms | 11.542679321s | | ||
| 1000 | 5M | 3900765363016383448 | 2.203334524s | 15.85451642s | | ||
| :--- | :--- | :--- | :--- | :--- | | ||
| 100 | 10K | 14371286973218730379 | 18.005544ms | 291.587072ms | | ||
| 100 | 100K | 18146878621059190265 | 186.174183ms | 3.055154731s | | ||
| 100 | 1M | 6839381432488849859 | 1.824378819s | 30.510083671s | | ||
| 500 | 2M | 12719220817276010307 | 5.17505883s | 303.150073635s | | ||
| 1000 | 5M | 16452801585435658354 | 14.711844242s | 1527.065366409s | | ||
|
||
The running time decomposition for the experiment with 1000 nodes and 5M random operations: | ||
The brute force solution takes time for `link(v, w)` and `cut(v, w)` operations where `size(v)` or `size(w)` is the number of points connected to the point. | ||
Then, `connected(v, w)` query can be performed in a constant time. | ||
However, `path(v, w)` operation takes `O(size(v) + size(w))` where `size(v) + size(w) = n` in the worst-case scenario for the brute force. | ||
On the other hand, all of these operations take `O(logn)` amortized time in the case of Link-cut trees. | ||
|
||
The time complexity analysis can be observed in practice on the last experiment with 1000 nodes and 5M random operations: | ||
|
||
| Operation | Count | [lctree](https://github.com/azizkayumov/lctree/blob/main/src/lctree.rs) | [brute-force](https://github.com/azizkayumov/lctree/blob/main/tests/test_random.rs) | | ||
| :--- | :--- | :--- | :--- | | ||
| link | 1249676 | 481.699835ms | 3.725153109s | | ||
| cut | 1246762 | 809.13079ms | 7.535368601s | | ||
| connected | 1249204 | 432.403952ms | 63.781244ms | | ||
| path | 1249798 | 480.099947ms | 4.530213466s | | ||
| link | 1249509 | 3.671253873s | 1.877281667s | | ||
| cut | 1251768 | 3.694333793s | 4.175882634s | | ||
| connected | 1250180 | 3.662950986s | 79.612576ms | | ||
| path | 1248543 | 3.68330559s | 1520.932589532s | |
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