Non-repeat random number scheme 1: 1531 milliseconds
The general idea is to first create an array of 1-3000, take out one at a time, and then reduce the array by one, take one, and reduce one, so that you can never repeat it.
[Ctrl+A Select all Note:Introducing external Js requires refreshing the page before execution]
Non-repeat random number scheme 2: 297 ms
However, Scheme 1 adopts the slice method. This method regenerates the array, which will consume a lot of memory and CPU operations, which is very inefficient, so improve it, take out a number from the original array, and then assign this position of the original array to null. In this way, when you get the number next time, you will be judged that if it is null, you will not take it until it is not null. After testing, it can significantly improve efficiency.
[Ctrl+A Select all Note:Introducing external Js requires refreshing the page before execution]
Non-repeat random number scheme 3: 234 ms
Change the idea, if you break up the original array origin and then print it in turn,
This can also be done randomly and never repeat, and it is more efficient.
Because the later the solution 2 runs, the higher the frequency of the original array being null, and the more times it will be.
[Ctrl+A Select all Note:Introducing external Js requires refreshing the page before execution]