Our code works correctly so far, but what about it's performance? Besides its readable syntax, liberal license, rich package ecosystem, and welcoming community, performance is one of the top reasons why data scientists and software developers choose Julia. The compiler does a great job of providing excellent performance out of the box, but there are certain best practices that we as developers must keep in mind to ensure that we basically don't hinder the compiler. We'll go over the most important ones by looking at a few examples while running some benchmarks.
Given its focus on performance, it should come as no surprise that both core Julia and the ecosystem provide a variety of tools for inspecting our code, looking for bottlenecks and measuring runtime and memory usage. One of the simplest is the @time
macro. It takes an expression and then prints its execution time, number of allocations, and the total number of bytes the execution caused to be allocated...