feat: print method has been added in HashMap. chore: reformated HashMap test. docs: high-performance HashMap benchmark

This commit is contained in:
Revone 2023-11-30 10:20:12 +08:00
parent 65949b7d19
commit 87ea490458
3 changed files with 23 additions and 19 deletions

View file

@ -782,52 +782,52 @@ avl2.print();
[//]: # (No deletion!!! Start of Replace Section)
<div class="json-to-html-collapse clearfix 0">
<div class='collapsible level0' ><span class='json-to-html-label'>avl-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>10,000 add randomly</td><td>33.09</td><td>30.22</td><td>4.32e-4</td></tr><tr><td>10,000 add & delete randomly</td><td>74.12</td><td>13.49</td><td>0.00</td></tr><tr><td>10,000 addMany</td><td>41.71</td><td>23.97</td><td>0.00</td></tr><tr><td>10,000 get</td><td>28.37</td><td>35.25</td><td>2.37e-4</td></tr></table></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>10,000 add randomly</td><td>30.05</td><td>33.28</td><td>6.97e-4</td></tr><tr><td>10,000 add & delete randomly</td><td>72.61</td><td>13.77</td><td>0.00</td></tr><tr><td>10,000 addMany</td><td>35.18</td><td>28.43</td><td>9.64e-4</td></tr><tr><td>10,000 get</td><td>30.02</td><td>33.31</td><td>5.36e-4</td></tr></table></div>
</div><div class="json-to-html-collapse clearfix 0">
<div class='collapsible level0' ><span class='json-to-html-label'>binary-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>1,000 add randomly</td><td>14.50</td><td>68.96</td><td>1.33e-4</td></tr><tr><td>1,000 add & delete randomly</td><td>16.20</td><td>61.72</td><td>2.03e-4</td></tr><tr><td>1,000 addMany</td><td>10.51</td><td>95.12</td><td>8.76e-5</td></tr><tr><td>1,000 get</td><td>18.28</td><td>54.69</td><td>1.82e-4</td></tr><tr><td>1,000 dfs</td><td>157.23</td><td>6.36</td><td>7.06e-4</td></tr><tr><td>1,000 bfs</td><td>58.06</td><td>17.22</td><td>0.01</td></tr><tr><td>1,000 morris</td><td>256.36</td><td>3.90</td><td>0.00</td></tr></table></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>1,000 add randomly</td><td>14.72</td><td>67.92</td><td>1.85e-4</td></tr><tr><td>1,000 add & delete randomly</td><td>18.55</td><td>53.90</td><td>3.16e-4</td></tr><tr><td>1,000 addMany</td><td>13.40</td><td>74.62</td><td>0.00</td></tr><tr><td>1,000 get</td><td>18.70</td><td>53.47</td><td>3.85e-4</td></tr><tr><td>1,000 has</td><td>19.28</td><td>51.87</td><td>0.00</td></tr><tr><td>1,000 dfs</td><td>158.14</td><td>6.32</td><td>0.01</td></tr><tr><td>1,000 bfs</td><td>56.98</td><td>17.55</td><td>8.96e-4</td></tr><tr><td>1,000 morris</td><td>260.83</td><td>3.83</td><td>0.00</td></tr></table></div>
</div><div class="json-to-html-collapse clearfix 0">
<div class='collapsible level0' ><span class='json-to-html-label'>bst</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>10,000 add randomly</td><td>30.48</td><td>32.81</td><td>4.13e-4</td></tr><tr><td>10,000 add & delete randomly</td><td>71.84</td><td>13.92</td><td>0.00</td></tr><tr><td>10,000 addMany</td><td>29.54</td><td>33.85</td><td>5.25e-4</td></tr><tr><td>10,000 get</td><td>30.53</td><td>32.75</td><td>0.01</td></tr></table></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>10,000 add randomly</td><td>26.61</td><td>37.58</td><td>6.20e-4</td></tr><tr><td>10,000 add & delete randomly</td><td>68.64</td><td>14.57</td><td>0.00</td></tr><tr><td>10,000 addMany</td><td>25.65</td><td>38.99</td><td>8.34e-5</td></tr><tr><td>10,000 get</td><td>33.11</td><td>30.21</td><td>0.02</td></tr></table></div>
</div><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</td><td>90.89</td><td>11.00</td><td>0.00</td></tr><tr><td>100,000 CPT add</td><td>50.65</td><td>19.74</td><td>0.00</td></tr><tr><td>100,000 add & delete randomly</td><td>230.08</td><td>4.35</td><td>0.02</td></tr><tr><td>100,000 getNode</td><td>38.97</td><td>25.66</td><td>5.82e-4</td></tr><tr><td>100,000 add & iterator</td><td>118.32</td><td>8.45</td><td>0.01</td></tr></table></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>85.61</td><td>11.68</td><td>0.00</td></tr><tr><td>100,000 add & delete randomly</td><td>214.04</td><td>4.67</td><td>0.01</td></tr><tr><td>100,000 getNode</td><td>154.49</td><td>6.47</td><td>4.10e-4</td></tr><tr><td>100,000 add & iterator</td><td>115.20</td><td>8.68</td><td>0.00</td></tr></table></div>
</div><div class="json-to-html-collapse clearfix 0">
<div class='collapsible level0' ><span class='json-to-html-label'>comparison</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>SRC PQ 10,000 add</td><td>0.14</td><td>6939.33</td><td>1.74e-6</td></tr><tr><td>CJS PQ 10,000 add</td><td>0.15</td><td>6881.64</td><td>1.91e-6</td></tr><tr><td>MJS PQ 10,000 add</td><td>0.57</td><td>1745.92</td><td>1.60e-5</td></tr><tr><td>CPT PQ 10,000 add</td><td>0.57</td><td>1744.71</td><td>1.01e-5</td></tr><tr><td>SRC PQ 10,000 add & pop</td><td>3.51</td><td>284.93</td><td>6.79e-4</td></tr><tr><td>CJS PQ 10,000 add & pop</td><td>3.42</td><td>292.55</td><td>4.04e-5</td></tr><tr><td>MJS PQ 10,000 add & pop</td><td>3.41</td><td>293.38</td><td>5.11e-5</td></tr><tr><td>CPT PQ 10,000 add & pop</td><td>2.09</td><td>478.76</td><td>2.28e-5</td></tr><tr><td>CPT OM 100,000 add</td><td>43.22</td><td>23.14</td><td>0.00</td></tr><tr><td>CPT HM 10,000 set</td><td>0.58</td><td>1721.25</td><td>1.85e-5</td></tr><tr><td>CPT HM 10,000 set & get</td><td>0.68</td><td>1477.31</td><td>1.26e-5</td></tr><tr><td>CPT LL 1,000,000 unshift</td><td>81.38</td><td>12.29</td><td>0.02</td></tr><tr><td>CPT PQ 10,000 add & pop</td><td>2.10</td><td>476.50</td><td>1.60e-4</td></tr><tr><td>CPT DQ 1,000,000 push</td><td>22.51</td><td>44.42</td><td>0.00</td></tr><tr><td>CPT Q 1,000,000 push</td><td>47.85</td><td>20.90</td><td>0.01</td></tr><tr><td>CPT ST 1,000,000 push</td><td>42.54</td><td>23.51</td><td>0.01</td></tr><tr><td>CPT ST 1,000,000 push & pop</td><td>50.08</td><td>19.97</td><td>0.00</td></tr></table></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>SRC PQ 10,000 add</td><td>0.16</td><td>6447.35</td><td>3.77e-5</td></tr><tr><td>CJS PQ 10,000 add</td><td>0.15</td><td>6865.39</td><td>5.18e-6</td></tr><tr><td>MJS PQ 10,000 add</td><td>0.58</td><td>1737.03</td><td>1.95e-5</td></tr><tr><td>SRC PQ 10,000 add & pop</td><td>3.44</td><td>290.59</td><td>6.14e-5</td></tr><tr><td>CJS PQ 10,000 add & pop</td><td>3.43</td><td>291.48</td><td>5.86e-5</td></tr><tr><td>MJS PQ 10,000 add & pop</td><td>4.29</td><td>233.18</td><td>1.71e-4</td></tr></table></div>
</div><div class="json-to-html-collapse clearfix 0">
<div class='collapsible level0' ><span class='json-to-html-label'>directed-graph</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>1,000 addVertex</td><td>0.11</td><td>9501.34</td><td>6.10e-6</td></tr><tr><td>1,000 addEdge</td><td>6.35</td><td>157.55</td><td>6.69e-4</td></tr><tr><td>1,000 getVertex</td><td>0.05</td><td>2.14e+4</td><td>2.50e-6</td></tr><tr><td>1,000 getEdge</td><td>25.00</td><td>39.99</td><td>0.01</td></tr><tr><td>tarjan</td><td>219.46</td><td>4.56</td><td>0.01</td></tr><tr><td>tarjan all</td><td>218.15</td><td>4.58</td><td>0.00</td></tr><tr><td>topologicalSort</td><td>176.83</td><td>5.66</td><td>0.00</td></tr></table></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>1,000 addVertex</td><td>0.10</td><td>9639.13</td><td>3.31e-6</td></tr><tr><td>1,000 addEdge</td><td>6.21</td><td>161.12</td><td>2.90e-4</td></tr><tr><td>1,000 getVertex</td><td>0.05</td><td>2.13e+4</td><td>1.42e-6</td></tr><tr><td>1,000 getEdge</td><td>27.34</td><td>36.57</td><td>0.01</td></tr><tr><td>tarjan</td><td>228.62</td><td>4.37</td><td>0.01</td></tr><tr><td>tarjan all</td><td>241.47</td><td>4.14</td><td>0.05</td></tr><tr><td>topologicalSort</td><td>193.23</td><td>5.18</td><td>0.02</td></tr></table></div>
</div><div class="json-to-html-collapse clearfix 0">
<div class='collapsible level0' ><span class='json-to-html-label'>hash-map</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>1,000,000 set</td><td>254.46</td><td>3.93</td><td>0.04</td></tr><tr><td>1,000,000 CPT set</td><td>251.21</td><td>3.98</td><td>0.03</td></tr><tr><td>1,000,000 Map set</td><td>211.27</td><td>4.73</td><td>0.01</td></tr><tr><td>1,000,000 Set add</td><td>175.15</td><td>5.71</td><td>0.02</td></tr><tr><td>1,000,000 set & get</td><td>370.54</td><td>2.70</td><td>0.11</td></tr><tr><td>1,000,000 CPT set & get</td><td>283.34</td><td>3.53</td><td>0.07</td></tr><tr><td>1,000,000 Map set & get</td><td>287.09</td><td>3.48</td><td>0.04</td></tr><tr><td>1,000,000 Set add & has</td><td>190.50</td><td>5.25</td><td>0.01</td></tr><tr><td>1,000,000 ObjKey set & get</td><td>880.47</td><td>1.14</td><td>0.10</td></tr><tr><td>1,000,000 Map ObjKey set & get</td><td>334.47</td><td>2.99</td><td>0.05</td></tr><tr><td>1,000,000 Set ObjKey add & has</td><td>310.12</td><td>3.22</td><td>0.06</td></tr></table></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>1,000,000 set</td><td>116.85</td><td>8.56</td><td>0.04</td></tr><tr><td>1,000,000 Map set</td><td>216.07</td><td>4.63</td><td>0.02</td></tr><tr><td>1,000,000 Set add</td><td>173.91</td><td>5.75</td><td>0.01</td></tr><tr><td>1,000,000 set & get</td><td>124.87</td><td>8.01</td><td>0.04</td></tr><tr><td>1,000,000 Map set & get</td><td>323.10</td><td>3.10</td><td>0.04</td></tr><tr><td>1,000,000 Set add & has</td><td>180.32</td><td>5.55</td><td>0.02</td></tr><tr><td>1,000,000 ObjKey set & get</td><td>335.51</td><td>2.98</td><td>0.07</td></tr><tr><td>1,000,000 Map ObjKey set & get</td><td>310.64</td><td>3.22</td><td>0.06</td></tr><tr><td>1,000,000 Set ObjKey add & has</td><td>271.15</td><td>3.69</td><td>0.05</td></tr></table></div>
</div><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 & pop</td><td>80.13</td><td>12.48</td><td>0.00</td></tr><tr><td>100,000 add & dfs</td><td>35.08</td><td>28.50</td><td>0.00</td></tr><tr><td>10,000 fib add & pop</td><td>367.84</td><td>2.72</td><td>0.01</td></tr></table></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 & pop</td><td>79.43</td><td>12.59</td><td>0.00</td></tr><tr><td>100,000 add & dfs</td><td>34.78</td><td>28.75</td><td>0.00</td></tr><tr><td>10,000 fib add & pop</td><td>356.18</td><td>2.81</td><td>0.00</td></tr></table></div>
</div><div class="json-to-html-collapse clearfix 0">
<div class='collapsible level0' ><span class='json-to-html-label'>doubly-linked-list</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>1,000,000 push</td><td>237.28</td><td>4.21</td><td>0.07</td></tr><tr><td>1,000,000 CPT push</td><td>75.66</td><td>13.22</td><td>0.03</td></tr><tr><td>1,000,000 unshift</td><td>226.38</td><td>4.42</td><td>0.05</td></tr><tr><td>1,000,000 CPT unshift</td><td>93.34</td><td>10.71</td><td>0.07</td></tr><tr><td>1,000,000 unshift & shift</td><td>188.34</td><td>5.31</td><td>0.05</td></tr><tr><td>1,000,000 insertBefore</td><td>329.60</td><td>3.03</td><td>0.05</td></tr></table></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>1,000,000 push</td><td>222.75</td><td>4.49</td><td>0.05</td></tr><tr><td>1,000,000 unshift</td><td>235.70</td><td>4.24</td><td>0.06</td></tr><tr><td>1,000,000 unshift & shift</td><td>179.26</td><td>5.58</td><td>0.04</td></tr><tr><td>1,000,000 insertBefore</td><td>340.92</td><td>2.93</td><td>0.07</td></tr></table></div>
</div><div class="json-to-html-collapse clearfix 0">
<div class='collapsible level0' ><span class='json-to-html-label'>singly-linked-list</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>10,000 push & pop</td><td>221.32</td><td>4.52</td><td>0.01</td></tr><tr><td>10,000 insertBefore</td><td>255.52</td><td>3.91</td><td>0.01</td></tr></table></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>10,000 push & pop</td><td>213.00</td><td>4.69</td><td>0.01</td></tr><tr><td>10,000 insertBefore</td><td>248.65</td><td>4.02</td><td>0.01</td></tr></table></div>
</div><div class="json-to-html-collapse clearfix 0">
<div class='collapsible level0' ><span class='json-to-html-label'>max-priority-queue</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>10,000 refill & poll</td><td>9.07</td><td>110.24</td><td>2.71e-4</td></tr></table></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>10,000 refill & poll</td><td>9.15</td><td>109.23</td><td>4.05e-4</td></tr></table></div>
</div><div class="json-to-html-collapse clearfix 0">
<div class='collapsible level0' ><span class='json-to-html-label'>priority-queue</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 & pop</td><td>101.93</td><td>9.81</td><td>7.95e-4</td></tr><tr><td>100,000 CPT add & pop</td><td>28.54</td><td>35.04</td><td>0.00</td></tr></table></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 & pop</td><td>102.30</td><td>9.78</td><td>0.00</td></tr></table></div>
</div><div class="json-to-html-collapse clearfix 0">
<div class='collapsible level0' ><span class='json-to-html-label'>deque</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>1,000,000 push</td><td>14.43</td><td>69.29</td><td>2.36e-4</td></tr><tr><td>1,000,000 CPT push</td><td>25.08</td><td>39.87</td><td>0.01</td></tr><tr><td>1,000,000 push & pop</td><td>22.87</td><td>43.72</td><td>6.05e-4</td></tr><tr><td>1,000,000 push & shift</td><td>25.28</td><td>39.55</td><td>0.01</td></tr><tr><td>1,000,000 unshift & shift</td><td>21.88</td><td>45.71</td><td>2.05e-4</td></tr></table></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>1,000,000 push</td><td>14.58</td><td>68.59</td><td>1.47e-4</td></tr><tr><td>1,000,000 push & pop</td><td>23.44</td><td>42.67</td><td>1.85e-4</td></tr><tr><td>1,000,000 push & shift</td><td>24.51</td><td>40.80</td><td>1.39e-4</td></tr><tr><td>1,000,000 unshift & shift</td><td>22.78</td><td>43.91</td><td>0.00</td></tr></table></div>
</div><div class="json-to-html-collapse clearfix 0">
<div class='collapsible level0' ><span class='json-to-html-label'>queue</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>1,000,000 push</td><td>38.49</td><td>25.98</td><td>9.08e-4</td></tr><tr><td>1,000,000 CPT push</td><td>43.93</td><td>22.76</td><td>0.01</td></tr><tr><td>1,000,000 push & shift</td><td>82.85</td><td>12.07</td><td>0.00</td></tr></table></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>1,000,000 push</td><td>39.36</td><td>25.41</td><td>0.01</td></tr><tr><td>1,000,000 push & shift</td><td>81.81</td><td>12.22</td><td>0.00</td></tr></table></div>
</div><div class="json-to-html-collapse clearfix 0">
<div class='collapsible level0' ><span class='json-to-html-label'>stack</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>1,000,000 push</td><td>40.19</td><td>24.88</td><td>0.01</td></tr><tr><td>1,000,000 CPT push</td><td>39.87</td><td>25.08</td><td>0.00</td></tr><tr><td>1,000,000 push & pop</td><td>41.67</td><td>24.00</td><td>0.01</td></tr><tr><td>1,000,000 CPT push & pop</td><td>46.65</td><td>21.44</td><td>0.00</td></tr></table></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>1,000,000 push</td><td>38.89</td><td>25.72</td><td>0.00</td></tr><tr><td>1,000,000 push & pop</td><td>44.21</td><td>22.62</td><td>0.01</td></tr></table></div>
</div><div class="json-to-html-collapse clearfix 0">
<div class='collapsible level0' ><span class='json-to-html-label'>trie</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 push</td><td>43.42</td><td>23.03</td><td>7.57e-4</td></tr><tr><td>100,000 getWords</td><td>93.41</td><td>10.71</td><td>0.00</td></tr></table></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 push</td><td>44.22</td><td>22.61</td><td>0.00</td></tr><tr><td>100,000 getWords</td><td>89.31</td><td>11.20</td><td>0.00</td></tr></table></div>
</div>
[//]: # (No deletion!!! End of Replace Section)

View file

@ -304,6 +304,10 @@ export class HashMap<K = any, V = any> {
return accumulator;
}
print(): void{
console.log([...this.entries()]);
}
protected _hashFn: (key: K) => string = (key: K) => String(key);
protected _isObjKey(key: any): key is (object | ((...args: any[]) => any)) {

View file

@ -245,7 +245,7 @@ describe('HashMap HOF', () => {
});
test('every() returns true if all elements match the condition', () => {
expect(hashMap.every((value, key) => typeof value === 'string')).toBe(true);
expect(hashMap.every((value) => typeof value === 'string')).toBe(true);
});
test('some() returns true if any element matches the condition', () => {
@ -259,7 +259,7 @@ describe('HashMap HOF', () => {
});
test('map() should transform each element', () => {
const newHashMap = hashMap.map((value, key) => value.toUpperCase());
const newHashMap = hashMap.map((value) => value.toUpperCase());
expect(newHashMap.get('key1')).toBe('VALUE1');
});
@ -269,7 +269,7 @@ describe('HashMap HOF', () => {
});
test('reduce() should accumulate values', () => {
const result = hashMap.reduce((acc, value, key) => acc + value, '');
const result = hashMap.reduce((acc, value) => acc + value, '');
expect(result).toBe('value1value2value3');
});
});