elixir_boards_benchmark

benchmark of multiple different possible representations of a 2D board in elixir

MIT License

Stars
8

ElixirBoardsBenchmark

A benchmark of different possible implementations of a 2D game board in elixir. The current benchmark is specifically for the board size 9x9.

What is a board implementation? See the Board behaviour - creating a new board, get(x, y) and set(x, y).

What is benchmarked?

  • get of (0, 0), (4, 4) and (8, 8)
  • set of (0, 0), (4, 4) and (8, 8)
  • getting and setting of (0, 0), (4, 4) and (8, 8)
  • getting and setting of all coordinates in one rune

The benchmarking code itself is in benchmark.exs.

Table of Contents

But Why?

Fun. No concrete use case at the moment other than looking at performance of different data structures in these circumstances. Additionally, this happened to have been one of the first questions I asked the elixir community.

Adding your own implemenation?

Have another implementation? Great! Add it to lib/board/ with a name describing the data structure, adopt the Board behaviour then add the module name to the module list in test/board_test.exs and benchmark.exs. Done! (if the tests pass and the benchmark runs of course)

Results

System Information

Getting and Setting Full Board

Run Time

Comparison

Memory Usage

Mixed Bag (3 sets, 3 gets)

Run Time

Comparison

Memory Usage

get(0,0)

Run Time

Comparison

get(4, 4)

Run Time

Comparison

get (8, 8)

Run Time

Comparison

set(0, 0)

Run Time

Comparison

set(4, 4)

Run Time

Comparison

set(8, 8)

Run Time

Comparison