Skip to content
Inefficient first N primes find web app for performance profiling
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Vanilla JS application to find first N primes to show performance profiling

Use code snippets


  • 0-profile-method-call - initial unoptimized application. Try finding 1000 primes, should take about 8 seconds.
  • 1-removed-try-catch - removed first bottleneck, should take less than 5 seconds.
  • 2-reuse-primes - reusing previously found primes, makes finding 10k primes very fast.

The next two steps require running static server in order to load the web worker script.

  • 3-web-worker - moved primes computation to a web worker.
  • 4-paint-profile - profile paint of expensive CSS property (box-shadow in index.html)

If you need angular version of this application, see bahmutov/primes.

Small print

Author: Gleb Bahmutov © 2014

License: MIT - do anything with the code, but don't blame me if it does not work.

Spread the word: tweet, star on github, etc.

Support: if you find any problems with this module, email / tweet / open issue on Github

You can’t perform that action at this time.