July 2017
Beginner to intermediate
358 pages
10h 54m
English
Benchmarking is a way of measuring the performance of your code by executing it multiple times with a fixed workload. We took a look at this briefly in Chapter 1, Introduction to Microservices, where we ascertained that the json.Marshal method was slower than the json.Encode method. While this is a useful feature, I find it tough to work out what I should benchmark. If I am writing an algorithm, then this is relatively straightforward. However, when writing a microservice that is predominately interacting with a database, it is far more challenging.
To demonstrate how easy it is to execute benchmarks in Go, take a look at chandlers/search_bench_test.go:
11 func BenchmarkSearchHandler(b *testing.B) { 12 mockStore = &data.MockStore{} ...Read now
Unlock full access