Skip to content

Commit 44f59f6

Browse files
Enhance benchmarking documentation for Golang by updating titles and improving clarity in descriptions across multiple sections.
1 parent 5d9d341 commit 44f59f6

File tree

1 file changed

+10
-10
lines changed
  • content/learning-paths/servers-and-cloud-computing/golang-on-azure

1 file changed

+10
-10
lines changed

content/learning-paths/servers-and-cloud-computing/golang-on-azure/benchmarking.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
2-
title: Perform Benchmark using go test -bench
2+
title: Run performance tests using go test -bench
33
weight: 6
44

55
### FIXED, DO NOT MODIFY
66
layout: learningpathall
77
---
88

9-
## Run performance tests using go test -bench
9+
## Performance benchmarking with Go's built-in testing framework
1010

1111
`go test -bench` is Go’s built-in benchmark runner. It repeatedly executes benchmark functions and reports latency (ns/op). With the `-benchmem` flag, it also reports memory usage (B/op) and allocations (allocs/op). It’s simple, reliable, and requires only writing benchmark functions in the standard Golang testing package.
1212

@@ -24,7 +24,7 @@ Initialize a new module:
2424
```console
2525
go mod init gosort-bench
2626
```
27-
This creates a `go.mod` file, which defines the module path (gosort-bench in this case) and marks the directory as a Go project. The `go.mod` file also allows Go to manage dependencies (external libraries) automatically, ensuring your project remains reproducible and easy to maintain.
27+
This creates a `go.mod` file, which defines the module path (`gosort-bench` in this case) and marks the directory as a Go project. The `go.mod` file also allows Go to manage dependencies (external libraries) automatically, ensuring your project remains reproducible and easy to maintain.
2828

2929
## Add sorting functions
3030

@@ -72,10 +72,10 @@ func partition(arr []int, low, high int) int {
7272
return i + 1
7373
}
7474
```
75-
The code contains two sorting methods, Bubble Sort and Quick Sort, which arrange numbers in order from smallest to largest:
75+
The code contains two sorting methods, *Bubble Sort* and *Quick Sort*, which arrange numbers in order from smallest to largest:
7676

77-
- Bubble Sort works by repeatedly comparing two numbers side by side and swapping them if they are in the wrong order. It keeps doing this until the whole list is sorted.
78-
- Quick Sort is faster. It picks a pivot number and splits the list into two groups. Numbers smaller than the pivot and numbers bigger than it. Then it sorts each group separately. The function partition helps Quick Sort decide where to split the list based on the pivot number.
77+
- *Bubble Sort* works by repeatedly comparing two numbers side by side and swapping them if they are in the wrong order. It keeps doing this until the whole list is sorted.
78+
- *Quick Sort* is faster. It picks a pivot number and splits the list into two groups. Numbers smaller than the pivot and numbers bigger than it. Then it sorts each group separately. The function partition helps Quick Sort decide where to split the list based on the pivot number.
7979

8080
To summarize, Bubble Sort is simple but slow, while Quick Sort is more efficient and usually much faster for big lists of numbers.
8181

@@ -133,7 +133,7 @@ The code implements a benchmark that measures the performance of Bubble Sort and
133133

134134
When you run the benchmark, Go will show you how long each sort takes and how much memory it uses, so you can compare the two sorting techniques.
135135

136-
### Run the Benchmark
136+
## Run the Benchmark
137137

138138
Execute the benchmark suite using the following command:
139139
```console
@@ -156,9 +156,9 @@ ok gosort-bench 2.905s
156156

157157
The metrics reported by go test -bench include ns/op, which measures nanoseconds per operation and reflects latency where lower values are better, B/op, which shows the number of bytes allocated per operation and helps identify memory efficiency, and allocs/op, which indicates the number of heap allocations per operation and highlights how often memory is being allocated, with lower values preferred in all cases.
158158

159-
### Benchmark summary on Arm64
159+
## Benchmark summary on Arm64
160160

161-
Results collected on an Arm64 **D4ps_v6** Ubuntu Pro 24.04 LTS virtual machine:
161+
Results collected on an Arm64 D4ps_v6 Ubuntu Pro 24.04 LTS virtual machine:
162162

163163
| Benchmark | Value |
164164
|----------------------|-------|
@@ -172,7 +172,7 @@ Results collected on an Arm64 **D4ps_v6** Ubuntu Pro 24.04 LTS virtual machine:
172172

173173
## Benchmark summary on x86-64
174174

175-
Results collected on an x86-64 **D4s_v6** Ubuntu Pro 24.04 LTS virtual machine:
175+
Results collected on an x86-64 D4s_v6 Ubuntu Pro 24.04 LTS virtual machine:
176176

177177
| Benchmark | Value on Virtual Machine |
178178
|-------------------|--------------------------|

0 commit comments

Comments
 (0)