Javascript code for making my browser slow down

后端 未结 8 1818
野性不改
野性不改 2021-02-19 02:28

I\'m writing a library for WebWorkers, and I want to test the difference between running a script in the main page thread, versus in one or more workers. The problem is: I can\'

8条回答
  •  盖世英雄少女心
    2021-02-19 03:01

    For some reason Bogosort comes to mind. Basically it's a sorting algorithm that consists of:

    while not list.isInOrder():
        list.randomize()
    

    It has an average complexity of O(n * n!) with little memory, so it should slow things down pretty good.

    The main downside is that its running time can be anywhere from O(n) to O(inf) (though really, O(inf) is pretty unlikely).

提交回复
热议问题