Skip to content

Commit 7357554

Browse files
committed
First review of resource usage on Window on Arm
1 parent 8ffc1df commit 7357554

File tree

4 files changed

+90
-50
lines changed

4 files changed

+90
-50
lines changed

content/learning-paths/laptops-and-desktops/win-resource-ps1/_index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ who_is_this_for: This is an introductory topic for developers who want to measur
1111

1212
learning_objectives:
1313
- Run video encode and decode tasks by using FFmpeg
14-
- Benchmark video encode task
15-
- Sample CPU / memory / power usage of video decode task
14+
- Benchmark the video encode task
15+
- Sample CPU, memory, and power usage for the video decode task
1616

1717
prerequisites:
1818
- A Windows on Arm computer such as the Lenovo Thinkpad X13s running Windows 11
19-
- Any code editor. [Visual Studio Code for Arm64](https://code.visualstudio.com/docs/?dv=win32arm64user) is suitable.
19+
- A code editor such as [Visual Studio Code for Windows on Arm](https://code.visualstudio.com/docs/?dv=win32arm64user)
2020

2121
author: Ruifeng Wang
2222

content/learning-paths/laptops-and-desktops/win-resource-ps1/how-to-1.md

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,65 @@
11
---
2-
title: Application and data set
2+
title: Set up FFmpeg and encode a test video
33
weight: 2
44

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

99
## Overview
10-
System resource usage provides an approach to understand the performance of an application as a black box. This Learning Path demonstrates how to sample system resource usage by using a script.
10+
System resource usage provides an approach to understand the performance of an application as a black box. This Learning Path demonstrates how to sample system resource usage using a script.
1111

12-
The application used is FFmpeg. It is a tool set that performs video encode and decode tasks. We will run the same tests with both x86_64 binary (through emulation) and Arm64 native binary.
12+
The example application you will use is FFmpeg, a tool set that performs video encode and decode tasks. You will run the same tests with both the x86_64 binary (using Windows instruction emulation) and the Arm64 native binary on a Windows on Arm computer.
1313

1414
## Application
15-
Binary builds are available. You don't need to build them from source. Download executable files for Windows:
15+
Binary builds of FFmpeg are available, so you don't need to build them from source.
1616

17-
1. Download [x86_64 package](https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2025-07-31-14-15/ffmpeg-n7.1.1-56-gc2184b65d2-win64-gpl-7.1.zip).
18-
2. Download [Arm64 native package](https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2025-07-31-14-15/ffmpeg-n7.1.1-56-gc2184b65d2-winarm64-gpl-7.1.zip).
17+
To get started:
1918

20-
Unzip the downloaded packages. You can find the binaries in **bin** folder. Note paths to **ffmpeg.exe** and **ffplay.exe**. They are used in later steps.
19+
1. Download the [FFmpeg x86_64 package](https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2025-07-31-14-15/ffmpeg-n7.1.1-56-gc2184b65d2-win64-gpl-7.1.zip).
20+
21+
2. Download the [FFmpeg Arm64 native package](https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2025-07-31-14-15/ffmpeg-n7.1.1-56-gc2184b65d2-winarm64-gpl-7.1.zip).
22+
23+
3. Unzip the downloaded packages.
24+
25+
You can find the binaries in the `bin` folder.
26+
27+
{{% notice Note %}}
28+
Make note of the paths to both versions of `ffmpeg.exe` and `ffplay.exe`, so you can run each one and compare the results.
29+
{{% /notice %}}
2130

2231
## Video source
23-
Download test video [RaceNight](https://ultravideo.fi/video/RaceNight_3840x2160_50fps_420_8bit_YUV_RAW.7z) from a public dataset. Unzip the package and note path to the uncompressed yuv file.
32+
Download the test video [RaceNight](https://ultravideo.fi/video/RaceNight_3840x2160_50fps_420_8bit_YUV_RAW.7z) from a public dataset.
33+
34+
Unzip the package and note the path to the uncompressed `.yuv` file.
2435

2536
## Video encoding
26-
The downloaded video file is in yuv raw format. It means playback of the video file involves no decoding effort. You need to encode the raw video with some compressing algorithms to add computation pressure at playback.
37+
The downloaded video file is in YUV raw format, which means playback of the video file involves no decoding effort. You need to encode the raw video with compression algorithms to add computation pressure during playback.
38+
39+
Use `ffmpeg.exe` to compress the YUV raw video with the x265 encoder and convert the file format to `.mp4`.
40+
41+
Open a terminal and run the following command:
2742

28-
Use **ffmpeg.exe** to compress the yuv raw video with x265 algorithm and convert file format to mp4. Open a terminal and run command:
2943
```console
3044
path\to\ffmpeg.exe -f rawvideo -pix_fmt yuv420p -s 3840x2160 -r 50 -i D:\path\to\RaceNight_YUV_RAW\RaceNight_3840x2160_50fps_8bit.yuv -vf scale=1920:1080 -c:v libx265 -preset medium -crf 20 D:\RaceNight_1080p.mp4 -benchmark -stats -report
3145
```
3246

3347
{{% notice Note %}}
34-
Modify the paths to `ffmpeg.exe` and yuv raw video file accordingly.
48+
Modify the paths to `ffmpeg.exe` and the YUV raw video file to match your locations.
3549
{{% /notice %}}
3650

37-
The command transforms video size, compresses the video into a H.265 encoded mp4 file. `benchmark` option is turned on to show performance data at the same time. The generated file is at D:\RaceNight_1080p.mp4.
51+
The command transforms the video size and compresses the video into an MP4 file using H.265 encoding (via the x265 encoder).
52+
53+
The `benchmark` option is turned on to show performance data at the same time.
54+
55+
The generated file will be at D:\RaceNight_1080p.mp4.
56+
57+
Run the command with both the x86_64 and the Arm64 versions of FFmpeg and compare the output.
3858

3959
### View results
40-
Shown below is example output from running x86_64 version ffmpeg.exe:
60+
61+
The output below is from the x86_64 version of `ffmpeg.exe`:
62+
4163
```output
4264
x265 [info]: tools: rd=3 psy-rd=2.00 early-skip rskip mode=1 signhide tmvp
4365
x265 [info]: tools: b-intra strong-intra-smoothing lslices=6 deblock sao
@@ -61,7 +83,8 @@ x265 [info]: Weighted P-Frames: Y:0.0% UV:0.0%
6183
encoded 600 frames in 71.51s (8.39 fps), 9075.96 kb/s, Avg QP:27.27
6284
```
6385

64-
Example output from running Arm64 native ffmpeg.exe:
86+
The output below is from the Arm64 native compiled `ffmpeg.exe`:
87+
6588
```output
6689
x265 [info]: tools: rd=3 psy-rd=2.00 early-skip rskip mode=1 signhide tmvp
6790
x265 [info]: tools: b-intra strong-intra-smoothing lslices=6 deblock sao
@@ -83,4 +106,8 @@ x265 [info]: frame B: 451, Avg QP:28.40 kb/s: 5878.38
83106
x265 [info]: Weighted P-Frames: Y:0.0% UV:0.0%
84107
85108
encoded 600 frames in 26.20s (22.90 fps), 9110.78 kb/s, Avg QP:27.23
86-
```
109+
```
110+
111+
The last line of each output shows the run time and the frames per second for each build of FFmpeg.
112+
113+
Continue to learn how to track resource usage and compare each version.

content/learning-paths/laptops-and-desktops/win-resource-ps1/how-to-2.md

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
---
2-
title: Tracking system resource
2+
title: Track system resources
33
weight: 3
44

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

9-
## Sampling video decoding resource usage
10-
A PowerShell script does all the work. It launches the video decoding task, samples CPU and memory usage, and outputs sampled data to a file with format.
9+
## Sample video decoding resource usage
10+
11+
To monitor resource usage during video decoding, use the following PowerShell script. This script starts the decoding process, periodically records CPU and memory statistics, and saves the results to a CSV file for analysis.
12+
13+
Open your code editor, copy the content below, and save it as `sample_decoding.ps1`.
1114

12-
Open your code editor, copy content below and save it as `sample_decoding.ps1`.
1315
```PowerShell { line_numbers = true }
1416
param (
1517
[string]$exePath = "path\to\ffplay.exe",
@@ -104,45 +106,49 @@ while (-not $process.HasExited) {
104106
}
105107
```
106108

107-
{{% notice Note %}}
108-
Modify the path to `ffplay.exe` on line 2 accordingly.
109-
{{% /notice %}}
109+
Before you run the script, modify the path to `ffplay.exe` on line 2 to match your installation location.
110110

111111
Run the script:
112+
112113
```console
113114
Set-ExecutionPolicy -Scope Process RemoteSigned
114115
.\sample_decoding.ps1
115116
```
116-
A video starts playing. It ends in 3 minutes. And then you can find the sample results file **usage_log.csv** in current directory.
117+
118+
A video starts playing and completes in 3 minutes. When finished, you can find the results file `usage_log.csv` in the current directory.
117119

118120
{{% notice Note %}}
119-
Script execution can be blocked due to policy configuration. The `Set-ExecutionPolicy` line allows local script to run during this session.
121+
Script execution may be blocked due to security policy configuration. The `Set-ExecutionPolicy` command allows local scripts to run during this session.
120122
{{% /notice %}}
121123

122-
### Script explained
123-
The `param` section defines variables including binary path, video playback arguments, sampling interval and result file path.
124+
### Script explanation
125+
126+
The `param` section defines variables including the binary path, video playback arguments, sampling interval, and result file path. You can modify these values as needed.
127+
128+
Lines 15-26 check and modify the binary file attributes. The binaries in use are downloaded from the web and may be blocked from running due to lack of digital signature. These lines unlock the binaries.
124129

125-
Line 15 - Line 26 check and modify binary file attribute. The binaries in use are downloaded from the web. They can be blocked to run due to lack of signature. These lines unlock the binaries.
130+
Line 41 retrieves all child processes of the main process. The statistical data includes resources used by all processes spawned by the main process.
126131

127-
Line 41 gets all the child processes of the main process. The statistic data include resources used by all the processes spawned by the main process.
132+
The `while` section collects CPU and memory usage periodically until the application exits. The CPU usage represents accumulated time that the process runs on the CPU. The memory usage shows the size of memory occupation with or without shared spaces accounted for.
128133

129-
The `while` setction collects processes' CPU and memory usage periodically until the application exits. The CPU usage is accumulated time length that the process runs on CPU. And the memory usage is size of memory occupation with or without shared spaces accounted.
134+
### View results
135+
136+
The output below shows the results from running the x86_64 version of `ffplay.exe`:
130137

131-
### View result
132-
Shown below is example sample result from running x86_64 version ffplay.exe:
133138
```output
134139
Timestamp,CPU Sum (s),Memory Sum (MB),Memory Private Sum (MB),CPU0 (s),Memory0 (MB),Memory Private0 (MB),CPU1 (s),Memory1 (MB),Memory Private1 (MB)
135140
2025-08-18T10:40:12.3480939+08:00,3.6875,378.65,342.16,3.671875,366.3515625,340.33984375,0.015625,12.296875,1.82421875
136141
......
137142
2025-08-18T10:43:09.7262439+08:00,396.375,391.71,355.00,396.359375,379.453125,353.2421875,0.015625,12.2578125,1.7578125
138143
```
139144

140-
Example result from running Arm64 native ffplay.exe:
145+
The output below shows the results from running the Arm64 version of `ffplay.exe`:
146+
141147
```output
142148
Timestamp,CPU Sum (s),Memory Sum (MB),Memory Private Sum (MB),CPU0 (s),Memory0 (MB),Memory Private0 (MB),CPU1 (s),Memory1 (MB),Memory Private1 (MB)
143149
2025-08-18T10:36:04.3654823+08:00,3.296875,340.51,328.17,3.28125,328.18359375,326.359375,0.015625,12.32421875,1.8125
144150
......
145151
2025-08-18T10:39:01.7856168+08:00,329.109375,352.53,339.96,329.09375,340.23046875,338.20703125,0.015625,12.30078125,1.75390625
146152
```
147153

148-
The sample result file is in **csv** format. You can open it with spreadsheet applications like Microsoft Excel for a better view and plot lines for data analysis.
154+
The sample result file uses CSV (comma-separated values) format. You can open it with spreadsheet applications like Microsoft Excel for better visualization and create charts for data analysis.

content/learning-paths/laptops-and-desktops/win-resource-ps1/how-to-3.md

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
---
2-
title: Measuring power usage
2+
title: Measure power usage
33
weight: 4
44

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

99
## Sampling battery status
10-
Querying battery status provides a way to measure power usage without an external power meter. It is also handy in that data collection and logging can be automatic.
1110

12-
A PowerShell script does all the work. It launches the video decoding task, samples battery status, and outputs sampled data to a file with format.
11+
Querying battery status provides a way to measure power usage without an external power meter. Battery monitoring is also convenient because data collection and logging can be automated.
12+
13+
A PowerShell script launches the video decoding task, samples battery status, and outputs the collected data to a CSV formatted file.
14+
15+
Open your code editor, copy the content below, and save it as `sample_power.ps1`:
1316

14-
Open your code editor, copy content below and save it as `sample_power.ps1`.
1517
```PowerShell { line_numbers = true }
1618
param (
1719
[string]$exePath = "path\to\ffplay.exe",
@@ -63,33 +65,38 @@ while (-not $process.HasExited) {
6365
}
6466
```
6567

66-
{{% notice Note %}}
67-
Modify the path to `ffplay.exe` on line 2 accordingly.
68-
{{% /notice %}}
68+
Before you run the script, modify the path to `ffplay.exe` on line 2 to match your installation location.
69+
70+
The battery data is system-based and process-agnostic. Fully charge the battery, close any unnecessary applications, unplug the power cord, and run the script:
6971

70-
The battery data is system based and process agnostic. Full charge the battery. Close any unnecessary applications. Unplug the power cord. And run the script:
7172
```console
7273
.\sample_power.ps1
7374
```
74-
A video starts playing. It ends in 30 minutes. And then you can find the sample results file **watts.csv** in current directory. The test runs for a longer time so you can observe a distinct battery remaining capacity drop.
7575

76-
The script collects battery remaining capacity and discharge rate periodically. You can track the battery remaining capacity to have an understanding of the power consumption.
76+
A video starts playing and completes in 30 minutes. When finished, you can find the results file `watts.csv` in the current directory. The test runs for a longer duration so you can observe a distinct drop in battery remaining capacity.
77+
78+
The script collects remaining battery capacity and discharge rate periodically. You can track the battery remaining capacity to understand the power consumption patterns.
79+
80+
### View results
81+
82+
The output below shows the results from running the x86_64 version of `ffplay.exe`:
7783

78-
### View result
79-
Shown below is example sample result from running x86_64 version ffplay.exe:
8084
```output
8185
Timestamp,RemainingCapacity(mWh),DischargeRate(mW)
8286
2025-08-15T14:42:50.5231628+08:00,48438,4347
8387
......
8488
2025-08-15T15:12:38.2028188+08:00,43823,8862
8589
```
8690

87-
Example result from running Arm64 native ffplay.exe:
91+
The output below shows the results from running the Arm64 version of `ffplay.exe`:
92+
8893
```output
8994
Timestamp,RemainingCapacity(mWh),DischargeRate(mW)
9095
2025-08-15T15:53:05.8430758+08:00,48438,3255
9196
......
9297
2025-08-15T16:22:55.3163530+08:00,44472,7319
9398
```
9499

95-
The sample result file is in **csv** format. You can open it with spreadsheet applications like Microsoft Excel for a better view and plot lines for data analysis.
100+
The sample results file is in CSV format. You can open it with spreadsheet applications like Microsoft Excel for better visualization and to plot data analysis charts.
101+
102+
Battery monitoring provides an effective way to measure power consumption differences between x86_64 and native Arm64 applications. By comparing discharge rates, you can quantify the power efficiency advantages that Arm processors typically demonstrate for video decoding workloads.

0 commit comments

Comments
 (0)