A developer sees several recorded response times and asks: was the whole run slow, or was there one busy stretch? A total and average show the overall picture; a consecutive window helps locate a burst.
Add profile to summarize supplied timing samples. Report their count, total, whole-number average, and largest K-sample window. You analyze recorded numbers; you do not benchmark the shell.
Input: One or more profile K sample... command lines, optionally followed by exit. Samples are nonnegative integer microseconds; 1 <= K <= the number of samples.
Output: For each profile command, print SAMPLES:n TOTAL_US:t AVG_US:a PEAK_WINDOW_US:p, with single spaces between fields.
Input:
profile 2 120 180 90 210 150
Output:
SAMPLES:5 TOTAL_US:750 AVG_US:150 PEAK_WINDOW_US:360
Explanation: The five samples total 750 and average 150. The two-sample sums are 300, 270, 300, and 360; the largest is 360.
Input:
profile 4 50 60 70 80
Output:
SAMPLES:4 TOTAL_US:260 AVG_US:65 PEAK_WINDOW_US:260
Explanation: The window covers the entire four-sample list, so its sum equals the total: 260. The average is 65.
Input:
profile 1 45 310 85 120
Output:
SAMPLES:4 TOTAL_US:560 AVG_US:140 PEAK_WINDOW_US:310
Explanation: A one-sample window asks for the largest individual sample: 310. The total is 560 and the average is 140.
Input:
profile 3 100 100 100 100 100
Output:
SAMPLES:5 TOTAL_US:500 AVG_US:100 PEAK_WINDOW_US:300
Explanation: Every three-sample window totals 300. Tied windows still produce one peak value, not several reports.
Input:
profile 2 10 15 12 400 450
Output:
SAMPLES:5 TOTAL_US:887 AVG_US:177 PEAK_WINDOW_US:850
Explanation: The last two samples form the largest window, 850. Whole-number division gives 887 divided by 5 as 177, not a decimal average.
Paste this into Custom Input and run your solution.
profile 2 10 20 30
If K changes to 1, which fields change?
Expected output:
SAMPLES:3 TOTAL_US:60 AVG_US:20 PEAK_WINDOW_US:50
Only PEAK_WINDOW_US changes, to 30. The count, total, and average describe the whole list and do not depend on window size.
After summing the first window, can you update it by adding one value and subtracting one value?
The same calculation appears in the window-statistics Prequel. Here you wrap it in a shell command and a labeled report. The timings are supplied data, not evidence of real shell performance.
Summarize a known command trace using counts and a deterministic tie rule.
SAMPLES:5 TOTAL_US:750 AVG_US:150 PEAK_WINDOW_US:360