flâneur — a map of the web's best reading

how fast is javascript simulating 20 000 000 particles

dgerrells.com · 7,339 words · saved by 1 readers

The challenge, simulate 1,000,000 particles in plain javascript at 60 fps on a phone using only the cpu. Let’s go. Ok, this is not a particularly difficult challenge if you did all the work on a gpu but the rule of the challenge is to use the CPU only or as much as possible and to stay in js land so no wasm. I know what you are thinking. This isn’t too hard. Just create an array and stick a million objects in it. Something like this maybe? Then you would just loop over your particles with something like this And assuming this is on a browser just toss that in a request animation frame with a canvas for rendering Now, this may be enough if you have a single fast cpu but mobile devices are not known for their single core performance. They have many small power efficient cores. And to hit the target, one million particles, I need to get as they say What is the fastest, most stablest, and predictable way of doing lots and lots of computations in any programming language? Tightly packed con

How fast is javascript? Simulating 20,000,000 particles Home / blog How fast is javascript? Simulating 20,000,000 particles The challenge, simulate 1,000,000 particles in plain javascript at 60 fps on a phone using only the cpu. Let's go. Ok, this is not a particularly difficult challenge if you did all the work on a gpu but the rule of the challenge is to use the CPU only or as much as possible and to stay in js land so no wasm. I know what you are thinking. This isn't too hard. Just create an array and stick a million objects in it. Something like this maybe? const count = 1 _000_000; const

Explore this link on the map →

related reading