In this repo is a simple script to measure the size of a CPU cache with javascript. It requires WebWorkers and ArrayBuffers, although could probably be adapted to not require either.
There really isn't that much special going on. Read cache_size_worker.js to get an idea of how the measurement is taking place - it is extensively commented. You can see a live demo here: https://fromwhenceitca.me/cache_size/cache_size.html
Licensed under the MIT license (see LICENSE file).