docs: Benchmarking metrics compared to native JavaScript

This commit is contained in:
Revone 2023-12-08 09:04:49 +08:00
parent a02a9a94d2
commit e167771620
4 changed files with 82 additions and 118 deletions

View file

@ -8,7 +8,7 @@ All notable changes to this project will be documented in this file.
- [Semantic Versioning](https://semver.org/spec/v2.0.0.html)
- [`auto-changelog`](https://github.com/CookPete/auto-changelog)
## [v1.48.6](https://github.com/zrwusa/data-structure-typed/compare/v1.35.0...main) (upcoming)
## [v1.48.7](https://github.com/zrwusa/data-structure-typed/compare/v1.35.0...main) (upcoming)
### Changes

126
README.md
View file

@ -17,78 +17,6 @@ Do you envy C++ with [STL]() (std::), Python with [collections](), and Java with
anymore! JavaScript and TypeScript now have [data-structure-typed]().**`Benchmark`** compared with C++ STL. **`API standards`** aligned with ES6 and Java. **`Usability`** is comparable to Python
### We provide data structures that are not available in JS/TS
Heap, Binary Tree, RedBlack Tree, Linked List, Deque, Trie, Directed Graph, Undirected Graph, BST, AVL Tree, Priority Queue, Queue, Tree Multiset, Linked List.
### Performance superior to native JS/TS
**`Queue vs. native Array, 100,000 scale`**
<table style="display: table; width:100%; table-layout: fixed;">
<thead>
<tr>
<th>Test Methods</th>
<th>Time Taken (ms)</th>
</tr>
</thead>
<tbody>
<tr>
<td>Queue push &amp; shift</td>
<td>5.83</td>
</tr>
<tr>
<td>Array push &amp; shift</td>
<td>2829.59</td>
</tr>
</tbody>
</table>
**`Deque vs. native Array, 100,000 scale`**
<table style="display: table; width:100%; table-layout: fixed;">
<thead>
<tr>
<th>Test Methods</th>
<th>Time Taken (ms)</th>
</tr>
</thead>
<tbody>
<tr>
<td>Deque unshift &amp; shift</td>
<td>2.44</td>
</tr>
<tr>
<td>Array unshift &amp; shift</td>
<td>4750.37</td>
</tr>
</tbody>
</table>
**`HashMap vs. native Map/Set, 100,000 scale`**
<table style="display: table; width:100%; table-layout: fixed;">
<thead>
<tr>
<th>Method</th>
<th>Time Taken (ms)</th>
</tr>
</thead>
<tbody>
<tr>
<td>HashMap 1,000,000 set</td>
<td>122.51</td>
</tr>
<tr>
<td>Native Map 1,000,000 set</td>
<td>223.80</td>
</tr>
<tr>
<td>Native Set 1,000,000 add</td>
<td>185.06</td>
</tr>
</tbody>
</table>
[//]: # (![Branches]&#40;https://img.shields.io/badge/branches-55.47%25-red.svg?style=flat&#41;)
[//]: # (![Statements]&#40;https://img.shields.io/badge/statements-67%25-red.svg?style=flat&#41;)
@ -97,6 +25,60 @@ Heap, Binary Tree, RedBlack Tree, Linked List, Deque, Trie, Directed Graph, Undi
[//]: # (![Lines]&#40;https://img.shields.io/badge/lines-68.6%25-red.svg?style=flat&#41;)
### We provide data structures that are not available in JS/TS
Heap, Binary Tree, RedBlack Tree, Linked List, Deque, Trie, Directed Graph, Undirected Graph, BST, AVL Tree, Priority Queue, Queue, Tree Multiset, Linked List.
### Performance surpasses that of native JS/TS
<table style="display: table; width:100%; table-layout: fixed;">
<thead>
<tr>
<th>Method</th>
<th>Time Taken (ms)</th>
<th>Scale</th>
</tr>
</thead>
<tbody>
<tr>
<td>Queue.push &amp; shift</td>
<td>5.83</td>
<td>100,000</td>
</tr>
<tr>
<td>Native Array.push &amp; shift</td>
<td>2829.59</td>
<td>100,000</td>
</tr>
<tr>
<td>Deque.unshift &amp; shift</td>
<td>2.44</td>
<td>100,000</td>
</tr>
<tr>
<td>Native Array.unshift &amp; shift</td>
<td>4750.37</td>
<td>100,000</td>
</tr>
<tr>
<td>HashMap.set </td>
<td>122.51</td>
<td>1,000,000</td>
</tr>
<tr>
<td>Native Map.set</td>
<td>223.80</td>
<td>1,000,000</td>
</tr>
<tr>
<td>Native Set.add</td>
<td>185.06</td>
<td>1,000,000</td>
</tr>
</tbody>
</table>
## Installation and Usage
Now you can use it in Node.js and browser environments

View file

@ -29,71 +29,53 @@ Heap, Binary Tree, RedBlack Tree, Linked List, Deque, Trie, Directed Graph, Undi
### 性能超越原生JS/TS
**`Queue和原生Array, 在100,000数据规模下性能对比`**
<table style="display: table; width:100%; table-layout: fixed;">
<thead>
<tr>
<th>Test Methods</th>
<th>Method</th>
<th>Time Taken (ms)</th>
<th>Scale</th>
</tr>
</thead>
<tbody>
<tr>
<td>Queue push &amp; shift</td>
<td>Queue.push &amp; shift</td>
<td>5.83</td>
<td>100,000</td>
</tr>
<tr>
<td>Array push &amp; shift</td>
<td>Native Array.push &amp; shift</td>
<td>2829.59</td>
<td>100,000</td>
</tr>
</tbody>
</table>
**`Deque和原生Array在100,000数据规模下的性能对比`**
<table style="display: table; width:100%; table-layout: fixed;">
<thead>
<tr>
<th>Test Methods</th>
<th>Time Taken (ms)</th>
</tr>
</thead>
<tbody>
<tr>
<td>Deque unshift &amp; shift</td>
<tr>
<td>Deque.unshift &amp; shift</td>
<td>2.44</td>
<td>100,000</td>
</tr>
<tr>
<td>Array unshift &amp; shift</td>
<td>Native Array.unshift &amp; shift</td>
<td>4750.37</td>
<td>100,000</td>
</tr>
<tr>
<td>HashMap.set </td>
<td>122.51</td>
<td>1,000,000</td>
</tr>
<tr>
<td>Native Map.set</td>
<td>223.80</td>
<td>1,000,000</td>
</tr>
<tr>
<td>Native Set.add</td>
<td>185.06</td>
<td>1,000,000</td>
</tr>
</tbody>
</table>
**`HashMap和原生Map/Set在100,000数据规模下的性能对比`**
<table style="display: table; width:100%; table-layout: fixed;">
<thead>
<tr>
<th>Method</th>
<th>Time Taken (ms)</th>
</tr>
</thead>
<tbody>
<tr>
<td>HashMap 1,000,000 set</td>
<td>122.51</td>
</tr>
<tr>
<td>Native Map 1,000,000 set</td>
<td>223.80</td>
</tr>
<tr>
<td>Native Set 1,000,000 add</td>
<td>185.06</td>
</tr>
</tbody>
</table>
[//]: # (![Branches]&#40;https://img.shields.io/badge/branches-55.47%25-red.svg?style=flat&#41;)
[//]: # (![Statements]&#40;https://img.shields.io/badge/statements-67%25-red.svg?style=flat&#41;)

View file

@ -1,6 +1,6 @@
{
"name": "data-structure-typed",
"version": "1.48.6",
"version": "1.48.7",
"description": "Data Structures of Javascript & TypeScript. Heap, Binary Tree, Red Black Tree, Linked List, Deque, Trie, HashMap, Directed Graph, Undirected Graph, Binary Search Tree(BST), AVL Tree, Priority Queue, Graph, Queue, Tree Multiset, Singly Linked List, Doubly Linked List, Max Heap, Max Priority Queue, Min Heap, Min Priority Queue, Stack. Benchmark compared with C++ STL. API aligned with ES6 and Java.util. Usability is comparable to Python",
"main": "dist/cjs/index.js",
"module": "dist/mjs/index.js",