mirror of
https://github.com/zrwusa/data-structure-typed.git
synced 2024-11-23 12:54:04 +00:00
test: RedBlackTree
This commit is contained in:
parent
a11c104dff
commit
1c2a70741b
20
README.md
20
README.md
|
@ -984,22 +984,28 @@ concurrently.
|
|||
|
||||
## Benchmark
|
||||
|
||||
MacBook Pro (15-inch, 2018)
|
||||
|
||||
Processor 2.2 GHz 6-Core Intel Core i7
|
||||
|
||||
Memory 16 GB 2400 MHz DDR4
|
||||
|
||||
Graphics Radeon Pro 555X 4 GB
|
||||
|
||||
Intel UHD Graphics 630 1536 MB
|
||||
|
||||
macOS Big Sur
|
||||
|
||||
Version 11.7.9
|
||||
|
||||
MacBook Pro (15-inch, 2018)
|
||||
Processor 2.2 GHz 6-Core Intel Core i7
|
||||
Memory 16 GB 2400 MHz DDR4
|
||||
Graphics Radeon Pro 555X 4 GB
|
||||
Intel UHD Graphics 630 1536 MB
|
||||
|
||||
[//]: # (No deletion!!! Start of Replace Section)
|
||||
<div class="json-to-html-collapse clearfix 0">
|
||||
<div class='collapsible level0' ><span class='json-to-html-label'>heap</span></div>
|
||||
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>100,000 add</td><td>6.46</td><td>154.91</td><td>3.36e-4</td></tr><tr><td>100,000 add & poll</td><td>31.62</td><td>31.62</td><td>8.04e-4</td></tr></table></div>
|
||||
</div><div id="json-to-html"><div class="json-to-html-collapse clearfix 0">
|
||||
<div class='collapsible level0' ><span class='json-to-html-label'>rb-tree</span></div>
|
||||
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>100,000 add orderly</td><td>92.78</td><td>10.78</td><td>0.00</td></tr><tr><td>100,000 add & delete orderly</td><td>164.95</td><td>6.06</td><td>0.00</td></tr><tr><td>100,000 add randomly</td><td>96.14</td><td>10.40</td><td>0.00</td></tr><tr><td>100,000 add & delete randomly</td><td>268.32</td><td>3.73</td><td>0.02</td></tr><tr><td>100,000 add & get randomly</td><td>221.23</td><td>4.52</td><td>0.00</td></tr><tr><td>100,000 add & iterator</td><td>130.01</td><td>7.69</td><td>0.01</td></tr></table></div>
|
||||
<div class="collapsible level0"><span class="json-to-html-label">rb-tree</span></div>
|
||||
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tbody><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>100,000 add</td><td>92.86</td><td>10.77</td><td>0.00</td></tr><tr><td>100,000 get</td><td>112.39</td><td>8.90</td><td>8.37e-4</td></tr><tr><td>100,000 iterator</td><td>30.56</td><td>32.72</td><td>0.00</td></tr><tr><td>100,000 add & delete orderly</td><td>175.06</td><td>5.71</td><td>0.02</td></tr><tr><td>100,000 add & delete randomly</td><td>263.48</td><td>3.80</td><td>0.00</td></tr></tbody></table></div>
|
||||
</div>
|
||||
|
||||
</div><div class="json-to-html-collapse clearfix 0">
|
||||
|
|
|
@ -11,37 +11,28 @@ const randomArray = getRandomIntArray(HUNDRED_THOUSAND, 0, HUNDRED_THOUSAND - 1,
|
|||
const cOrderedMap = new OrderedMap<number, number>();
|
||||
|
||||
suite
|
||||
.add(`${HUNDRED_THOUSAND.toLocaleString()} add orderly`, () => {
|
||||
.add(`${HUNDRED_THOUSAND.toLocaleString()} add`, () => {
|
||||
rbTree.clear();
|
||||
for (let i = 0; i < randomArray.length; i++) rbTree.add(i);
|
||||
})
|
||||
.add(`${HUNDRED_THOUSAND.toLocaleString()} get`, () => {
|
||||
for (let i = 0; i < randomArray.length; i++) rbTree.get(randomArray[i]);
|
||||
})
|
||||
.add(`${HUNDRED_THOUSAND.toLocaleString()} iterator`, () => {
|
||||
const entries = [...rbTree];
|
||||
return entries.length === HUNDRED_THOUSAND;
|
||||
})
|
||||
.add(`${HUNDRED_THOUSAND.toLocaleString()} add & delete orderly`, () => {
|
||||
rbTree.clear();
|
||||
for (let i = 0; i < randomArray.length; i++) rbTree.add(i);
|
||||
for (let i = 0; i < randomArray.length; i++) rbTree.delete(i);
|
||||
})
|
||||
.add(`${HUNDRED_THOUSAND.toLocaleString()} add randomly`, () => {
|
||||
rbTree.clear();
|
||||
for (let i = 0; i < randomArray.length; i++) rbTree.add(randomArray[i]);
|
||||
})
|
||||
.add(`${HUNDRED_THOUSAND.toLocaleString()} add & delete randomly`, () => {
|
||||
rbTree.clear();
|
||||
for (let i = 0; i < randomArray.length; i++) rbTree.add(randomArray[i]);
|
||||
for (let i = 0; i < randomArray.length; i++) rbTree.delete(randomArray[i]);
|
||||
})
|
||||
.add(`${HUNDRED_THOUSAND.toLocaleString()} add & get randomly`, () => {
|
||||
rbTree.clear();
|
||||
for (let i = 0; i < randomArray.length; i++) rbTree.add(randomArray[i]);
|
||||
for (let i = 0; i < randomArray.length; i++) rbTree.get(randomArray[i]);
|
||||
});
|
||||
|
||||
suite.add(`${HUNDRED_THOUSAND.toLocaleString()} add & iterator`, () => {
|
||||
rbTree.clear();
|
||||
for (let i = 0; i < randomArray.length; i++) rbTree.add(randomArray[i]);
|
||||
const entries = [...rbTree];
|
||||
return entries.length === HUNDRED_THOUSAND;
|
||||
});
|
||||
|
||||
if (isCompetitor) {
|
||||
suite.add(`CPT ${HUNDRED_THOUSAND.toLocaleString()} add`, () => {
|
||||
for (let i = 0; i < randomArray.length; i++) cOrderedMap.setElement(randomArray[i], randomArray[i]);
|
||||
|
|
Loading…
Reference in a new issue