mirror of
https://github.com/zrwusa/data-structure-typed.git
synced 2024-11-23 12:54:04 +00:00
docs: Chinese version README.md
This commit is contained in:
parent
3cd5316f2a
commit
d038e03ef2
53
README.md
53
README.md
|
@ -9,15 +9,62 @@
|
|||
|
||||
[//]: # (![npm bundle size](https://img.shields.io/bundlephobia/min/data-structure-typed))
|
||||
|
||||
## Why
|
||||
|
||||
<p><a href="https://github.com/zrwusa/data-structure-typed/blob/main/README.md">English</a> | <a href="https://github.com/zrwusa/data-structure-typed/blob/main/README_zh-CN.md">简体中文</a></p>
|
||||
|
||||
|
||||
Data Structures of Javascript & TypeScript.
|
||||
|
||||
Do you envy C++ with [STL]() (std::), Python with [collections](), and Java with [java.util]() ? Well, no need to envy
|
||||
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 JavaScript/TypeScript
|
||||
|
||||
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 JavaScript/TypeScript
|
||||
|
||||
**`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 & shift</td>
|
||||
<td>5.83</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Array push & 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 & shift</td>
|
||||
<td>2.44</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Array unshift & shift</td>
|
||||
<td>4750.37</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
[//]: # (![Branches](https://img.shields.io/badge/branches-55.47%25-red.svg?style=flat))
|
||||
|
||||
[//]: # (![Statements](https://img.shields.io/badge/statements-67%25-red.svg?style=flat))
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
[//]: # (![npm bundle size](https://img.shields.io/bundlephobia/min/data-structure-typed))
|
||||
|
||||
## 为什么
|
||||
|
||||
<p><a href="https://github.com/zrwusa/data-structure-typed/blob/main/README.md">English</a> | <a href="https://github.com/zrwusa/data-structure-typed/blob/main/README_zh-CN.md">简体中文</a></p>
|
||||
|
||||
JavaScript和TypeScript的数据结构。
|
||||
|
@ -19,6 +21,54 @@ JavaScript和TypeScript的数据结构。
|
|||
|
||||
**`基准测试`** 与C++ STL相比。**`API 标准`** 与ES6和Java对齐。**`易用性`** 可与Python媲美。
|
||||
|
||||
|
||||
### 提供了JavaScript/TypeScript中没有的数据结构
|
||||
|
||||
Heap, Binary Tree, RedBlack Tree, Linked List, Deque, Trie, Directed Graph, Undirected Graph, BST, AVL Tree, Priority Queue, Queue, Tree Multiset, Linked List.
|
||||
|
||||
|
||||
### 性能超越原生JavaScript/TypeScript
|
||||
|
||||
**`Queue和原生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>Queue push & shift</td>
|
||||
<td>5.83</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Array push & shift</td>
|
||||
<td>2829.59</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 & shift</td>
|
||||
<td>2.44</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Array unshift & shift</td>
|
||||
<td>4750.37</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
[//]: # (![Branches](https://img.shields.io/badge/branches-55.47%25-red.svg?style=flat))
|
||||
|
||||
[//]: # (![Statements](https://img.shields.io/badge/statements-67%25-red.svg?style=flat))
|
||||
|
|
|
@ -5,7 +5,7 @@ import { magnitude } from '../../../utils';
|
|||
import { isCompetitor } from '../../../config';
|
||||
|
||||
export const suite = new Benchmark.Suite();
|
||||
const { LINEAR } = magnitude;
|
||||
const { LINEAR, HUNDRED_THOUSAND } = magnitude;
|
||||
|
||||
suite.add(`${LINEAR.toLocaleString()} push`, () => {
|
||||
const deque = new Deque<number>();
|
||||
|
@ -26,16 +26,28 @@ suite.add(`${LINEAR.toLocaleString()} push & pop`, () => {
|
|||
for (let i = 0; i < LINEAR; i++) _deque.push(i);
|
||||
for (let i = 0; i < LINEAR; i++) _deque.pop();
|
||||
|
||||
});
|
||||
suite.add(`${LINEAR.toLocaleString()} push & shift`, () => {
|
||||
const _deque = new Deque<number>();
|
||||
})
|
||||
.add(`${HUNDRED_THOUSAND.toLocaleString()} push & shift`, () => {
|
||||
const _deque = new Deque<number>();
|
||||
|
||||
for (let i = 0; i < LINEAR; i++) _deque.push(i);
|
||||
for (let i = 0; i < LINEAR; i++) _deque.shift();
|
||||
});
|
||||
suite.add(`${LINEAR.toLocaleString()} unshift & shift`, () => {
|
||||
const _deque = new Deque<number>();
|
||||
for (let i = 0; i < HUNDRED_THOUSAND; i++) _deque.push(i);
|
||||
for (let i = 0; i < HUNDRED_THOUSAND; i++) _deque.shift();
|
||||
})
|
||||
.add(`${HUNDRED_THOUSAND.toLocaleString()} Array push & shift`, () => {
|
||||
const _deque = new Array<number>();
|
||||
|
||||
for (let i = 0; i < LINEAR; i++) _deque.unshift(i);
|
||||
for (let i = 0; i < LINEAR; i++) _deque.shift();
|
||||
});
|
||||
for (let i = 0; i < HUNDRED_THOUSAND; i++) _deque.push(i);
|
||||
for (let i = 0; i < HUNDRED_THOUSAND; i++) _deque.shift();
|
||||
})
|
||||
.add(`${HUNDRED_THOUSAND.toLocaleString()} unshift & shift`, () => {
|
||||
const _deque = new Deque<number>();
|
||||
|
||||
for (let i = 0; i < HUNDRED_THOUSAND; i++) _deque.unshift(i);
|
||||
for (let i = 0; i < HUNDRED_THOUSAND; i++) _deque.shift();
|
||||
})
|
||||
.add(`${HUNDRED_THOUSAND.toLocaleString()} Array unshift & shift`, () => {
|
||||
const _deque = new Array<number>();
|
||||
|
||||
for (let i = 0; i < HUNDRED_THOUSAND; i++) _deque.unshift(i);
|
||||
for (let i = 0; i < HUNDRED_THOUSAND; i++) _deque.shift();
|
||||
});
|
||||
|
|
|
@ -51,7 +51,7 @@ suite.add(`${HUNDRED_THOUSAND.toLocaleString()} Array push & shift`, () => {
|
|||
}
|
||||
|
||||
for (let i = 0; i < HUNDRED_THOUSAND; i++) {
|
||||
arr.shift();
|
||||
arr.pop();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue