Jakub Jarosz

Systems & Network Automation

Performance Tuning and Benchmarking

2024-11-02 Go Books Jakub Jarosz

Have you ever wondered how to determine if your Go code is performing at its best?



Benchmarks help you spot slow code and fix it. They also help you choose the best data structures and algorithms. By the end of this book, you will know how to write benchmarks that guide your engineering decisions.


What you will learn

By reading through the book and completing the exercises, you will learn:

  • How to write benchmarking tests from scratch
  • How to convert your regular tests into benchmarks
  • How to interpret benchmarking results
  • How to structure table-driven benchmarks
  • How to run benchmarks in parallel
  • How to avoid common mistakes
  • How to compare benchmarks
  • How to speed up code and reduce memory use by choosing the right data structures and algorithms
  • How to run benchmarking as a part of CI pipelines using GitHub Action

By mastering these skills, you will improve your understanding of the code. It will help you decide if your project requires refactoring. And if you or your team are making effective use of engineering time. With data on how and why to improve the code, you’ll be better able to make a business case for a change request.

You will learn if and why chasing nanoseconds wastes engineering time in some cases. Knowing trade-offs and making informed decisions will make you a better engineer.

Table of Contents

  1. Inroduction to benchmarking
  2. Using the Go test tool
  3. Benchmarking internals
  4. Structuring benchmarks
  5. Managing the benchmark timer
  6. Cleaning up after benchmarks
  7. Running table-driven benchmarks
  8. Running benchmarks in parallel
  9. Ensuring benchmarks accuracy
  10. Comparing benchmarks
  11. Running benchmarks in CI pipelines

Signup to our mailing list below and we’ll let you know as soon as the first chapter is released.