Sorting is a commonly used programming example. what is the performance of various sorting in JavaScript? The data tested by each browser is different. For example, if I use chrome for testing, the fast sorting will usually be the fastest, and IE may be the fastest in the Shile according to the array length. Do not use too much data to test the bubble sorting (I don't care if the browser crashes ).
Sorting is a commonly used programming example. what is the performance of various sorting in JavaScript? The data tested by each browser is different. For example, if I use chrome for testing, the fast sorting will usually be the fastest, and IE may be the fastest in the Shile according to the array length.
Do not use too much data to test the bubble sorting (I don't care if the browser crashes ).
[,] Quick sorting Insert sort Hill Sorting System Method Bubble sorting ClearTest array length:
Number of Tests: 10
The array is too long. please use bubble sort with caution.
| Algorithm |
Array length |
Time difference (MS) |
Average (MS) |
Click Test |
| Quick sorting |
|
|
|
Test |
| Insert sort |
|
|
|
Test |
| Hill Sorting |
|
|
|
Test |
| System Method |
|
|
|
Test |
| Bubble sorting |
|
|
|
Test with caution |
Personal understanding:
- Bubble sorting: the simplest and slowest. it seems that the length is smaller than 7.
- Insert sorting: it is faster than bubble, and slower than fast sorting and Hill sorting. smaller data has advantages.
- Fast sorting: this is a very fast sorting method. the V8 sort method uses the combination of fast sorting and insert sorting.
- Hill Sorting: In non-chrome, the array length is less than 1000, and the Hill sorting is faster
- System Method: The system method in forfox is very fast.
JavaScript Code