|
1 | 1 | --- |
2 | | -title: Tracking system resource |
| 2 | +title: Track system resources |
3 | 3 | weight: 3 |
4 | 4 |
|
5 | 5 | ### FIXED, DO NOT MODIFY |
6 | 6 | layout: learningpathall |
7 | 7 | --- |
8 | 8 |
|
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`. |
11 | 14 |
|
12 | | -Open your code editor, copy content below and save it as `sample_decoding.ps1`. |
13 | 15 | ```PowerShell { line_numbers = true } |
14 | 16 | param ( |
15 | 17 | [string]$exePath = "path\to\ffplay.exe", |
@@ -104,45 +106,49 @@ while (-not $process.HasExited) { |
104 | 106 | } |
105 | 107 | ``` |
106 | 108 |
|
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. |
110 | 110 |
|
111 | 111 | Run the script: |
| 112 | + |
112 | 113 | ```console |
113 | 114 | Set-ExecutionPolicy -Scope Process RemoteSigned |
114 | 115 | .\sample_decoding.ps1 |
115 | 116 | ``` |
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. |
117 | 119 |
|
118 | 120 | {{% 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. |
120 | 122 | {{% /notice %}} |
121 | 123 |
|
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. |
124 | 129 |
|
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. |
126 | 131 |
|
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. |
128 | 133 |
|
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`: |
130 | 137 |
|
131 | | -### View result |
132 | | -Shown below is example sample result from running x86_64 version ffplay.exe: |
133 | 138 | ```output |
134 | 139 | 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) |
135 | 140 | 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 |
136 | 141 | ...... |
137 | 142 | 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 |
138 | 143 | ``` |
139 | 144 |
|
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 | + |
141 | 147 | ```output |
142 | 148 | 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) |
143 | 149 | 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 |
144 | 150 | ...... |
145 | 151 | 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 |
146 | 152 | ``` |
147 | 153 |
|
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. |
0 commit comments