Skip to content

Commit 8ca3cda

Browse files
Refactor benchmarking.md for clarity and consistency
Updated terminology from 'aarch64' to 'Arm64' for consistency. Revised sections for clarity and improved readability.
1 parent 74396fb commit 8ca3cda

1 file changed

Lines changed: 12 additions & 34 deletions

File tree

  • content/learning-paths/servers-and-cloud-computing/rust-on-gcp

content/learning-paths/servers-and-cloud-computing/rust-on-gcp/benchmarking.md

Lines changed: 12 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ weight: 6
66
layout: learningpathall
77
---
88

9-
## Benchmark Rust performance
9+
## Overview
1010

11-
This section demonstrates how to benchmark Rust performance using `cargo bench` and the Criterion library to measure code execution speed and performance consistency on aarch64 hardware.
11+
This section demonstrates how to benchmark Rust performance using `cargo bench` and the Criterion library to measure code execution speed and performance consistency on Arm64 hardware.
1212

13-
### Create a benchmark project
13+
## Create a benchmark project
1414

1515
Create a new Rust project specifically for benchmarking:
1616

@@ -19,9 +19,9 @@ cargo new rust-benchmark
1919
cd rust-benchmark
2020
```
2121

22-
### Configure Criterion as a dependency
22+
## Configure Criterion as a dependency
2323

24-
Criterion is the recommended benchmarking crate for Rust. Edit the `Cargo.toml` file in your project root directory and replace the existing content with:
24+
Criterion is the recommended benchmarking crate for Rust. Open the `Cargo.toml` file in your project root directory and replace the existing content with:
2525

2626
```toml
2727
[dependencies]
@@ -34,21 +34,15 @@ harness = false
3434

3535
This configuration enables Criterion for high-precision benchmarking and disables the default test harness.
3636

37-
### Create the benchmark directory and file
37+
## Create the benchmark directory and file
3838

3939
Create the benchmark structure that Cargo expects:
4040

4141
```console
4242
mkdir benches
4343
```
4444

45-
Create a new benchmark file in the `benches/` directory:
46-
47-
```console
48-
edit benches/my_benchmark.rs
49-
```
50-
51-
Add the following benchmark code to measure Fibonacci number calculation performance:
45+
Create a new file named `my_benchmark.rs` in the `benches/` directory and add the following benchmark code to measure Fibonacci number calculation performance:
5246

5347
```rust
5448
use criterion::{black_box, Criterion, criterion_group, criterion_main};
@@ -72,7 +66,7 @@ criterion_main!(benches);
7266

7367
This code implements a recursive Fibonacci function and measures how efficiently Rust computes the 20th Fibonacci number. The `black_box` function prevents the compiler from optimizing away the benchmark.
7468

75-
### Run the benchmark
69+
## Run the benchmark
7670

7771
Execute the benchmark using Cargo:
7872

@@ -92,29 +86,13 @@ Found 1 outliers among 100 measurements (1.00%)
9286
1 (1.00%) low mild
9387
```
9488

95-
### Benchmark Metrics Explanation
96-
97-
- **Average Time:** Mean execution time across benchmark runs.
98-
- **Outliers:** Represent runs significantly slower or faster than average.
99-
- **Plotting Backend:** Used `plotters` since Gnuplot was not found.
100-
- The results show **consistent performance** with only slight variation across 100 measurements.
101-
102-
### Understand the results
103-
104-
The benchmark output provides several key metrics:
105-
106-
- **Average time**: Mean execution time across benchmark runs
107-
- **Outliers**: Runs significantly slower or faster than average
108-
- **Plotting backend**: Uses plotters since Gnuplot wasn't found
109-
110-
The results show consistent performance with only slight variation across 100 measurements.
111-
112-
### Performance summary
89+
## Performance summary
90+
The benchmark output provides several key metrics: the average time represents the mean execution time across benchmark runs, outliers identify runs that were significantly slower or faster than average, and the plotting backend indicates that plotters is being used since Gnuplot wasn't found on the system.
11391

114-
The following table shows results from running the benchmark on a `c4a-standard-4` (4 vCPU, 16 GB memory) aarch64 VM in GCP using SUSE:
92+
The following table shows results from running the benchmark on a `c4a-standard-4` (4 vCPU, 16 GB memory) Arm64 VM in GCP using SUSE:
11593

11694
| Benchmark | Average Time (µs) | Min (µs) | Max (µs) | Outliers (%) | Remarks |
11795
|---------------|------------------:|---------:|---------:|-------------:|---------|
11896
| fibonacci 20 | 12.028 | 12.026 | 12.030 | 1.00% | Stable performance with minimal variation |
11997

120-
The Fibonacci benchmark demonstrates consistent performance on the aarch64 platform. The average execution time of 12.028 µs indicates efficient CPU computation, while only 1% of measurements were outliers. This low variance confirms Rust's reliable execution speed and performance stability on aarch64 architecture.
98+
The Fibonacci benchmark demonstrates consistent performance on the Arm64 platform. The average execution time of 12.028 µs indicates efficient CPU computation, while only 1% of measurements were outliers. This low variance confirms Rust's reliable execution speed and performance stability on Arm64 architecture.

0 commit comments

Comments
 (0)