Using Benchee to Analyze Performance
Learn how Benchee can be added to the framework defined so far.
We'll cover the following...
Adding Benchee to the framework
If the optimization seems necessary, the first thing to do is establish a baseline.
Benchee is an Elixir benchmarking package that’s easy to use and provides a lot of information out of the box. We’ll use Benchee to benchmark the different aspects of our genetic algorithms.
We will start by adding Benchee to our dependencies in mix.exs
:
defp deps do# ... other deps{:benchee, ~> "1.0.1"}end
Next, we will create a new file benchmark.exs
in a new directory bench
. We’ll declare the basic benchmarks of each of our core functions in this file.
Benchmarks are typically done on large parts of programs. In this example, we’ll benchmark each of the core functions in your genetic algorithm framework, and we’ll also benchmark a single evolution. To do this, we need to declare a ...