AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Wormhole software4/6/2024 However, let’s apply a computing wormhole and change the size of the array to a magic number: // Change the size of the list from 15000 to 16384 On my computer it takes ~4s to run that benchmark with 1 billion inserts. Let’s run a simple benchmark console.time() Using it here makes i loop around the list size. the number on the left of it with the number on the right. The % operator is called modulo, and returns the remainder when dividing Let’s say we want to implement a circular list.Ī circular list is a list that has a fixed size, where inserts larger than the list size loop around the list.Ĭircular lists are useful for a bunch of things such as collecting stats at regular time intervals, buffering data and more, but let’s just look at an implementation of this: const list = new Array(15000) What exactly do we mean by this? Let’s look at an example. If we know what the computer is really fast at, we can take shortcuts, or wormholes, to make our programs run much faster than we’d expect them to. It turns out the computer is much faster at certain kinds of math versus others. The automated mathematician, however, is a deceptive abstraction. From a theoretical point of view, we tend to think of them as automated mathematicians, or put another way, just really good at adding, multiplying, and working with numbers in general. If you are writing JavaScript (or any other language) and care about performance for algorithms, it’s important to understand how computers work underneath.Ĭomputers are interesting machines.
0 Comments
Read More
Leave a Reply. |