mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-11-02 17:11:28 +00:00
Improve plot_progression.py script
This commit is contained in:
1 parent
a75dca90e1
commit
c7be935da3
1 file changed
+29
-13
+29
-13
@@ -30,32 +30,48 @@ parser.add_argument(
|
|||||||
metavar="num_runs",
|
metavar="num_runs",
|
||||||
help="Width of the moving-average window (default: N/5)",
|
help="Width of the moving-average window (default: N/5)",
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--no-moving-average",
|
||||||
|
action="store_true",
|
||||||
|
help="Do not show moving average curve",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
with open(args.file) as f:
|
with open(args.file) as f:
|
||||||
results = json.load(f)["results"]
|
results = json.load(f)["results"]
|
||||||
|
|
||||||
label = results[0]["command"]
|
for result in results:
|
||||||
times = results[0]["times"]
|
label = result["command"]
|
||||||
num = len(times)
|
times = result["times"]
|
||||||
nums = range(num)
|
num = len(times)
|
||||||
|
nums = range(num)
|
||||||
|
|
||||||
plt.scatter(x=nums, y=times, marker=".", color="orange")
|
plt.scatter(x=nums, y=times, marker=".")
|
||||||
plt.ylim([0, None])
|
plt.ylim([0, None])
|
||||||
plt.xlim([-1, num])
|
plt.xlim([-1, num])
|
||||||
|
|
||||||
moving_average_width = (
|
if not args.no_moving_average:
|
||||||
num // 5 if args.moving_average_width is None else args.moving_average_width
|
moving_average_width = (
|
||||||
)
|
num // 5 if args.moving_average_width is None else args.moving_average_width
|
||||||
|
)
|
||||||
|
|
||||||
moving_average = moving_average(times, moving_average_width)
|
average = moving_average(times, moving_average_width)
|
||||||
plt.plot(nums, moving_average, "-", color="blue")
|
plt.plot(nums, average, "-")
|
||||||
|
|
||||||
if args.title:
|
if args.title:
|
||||||
plt.title(args.title)
|
plt.title(args.title)
|
||||||
plt.legend(labels=[label], loc="best", fontsize="medium")
|
|
||||||
|
legend = []
|
||||||
|
for result in results:
|
||||||
|
legend.append(result["command"])
|
||||||
|
if not args.no_moving_average:
|
||||||
|
legend.append("moving average")
|
||||||
|
plt.legend(legend)
|
||||||
|
|
||||||
plt.ylabel("Time [s]")
|
plt.ylabel("Time [s]")
|
||||||
|
|
||||||
if args.output:
|
if args.output:
|
||||||
plt.savefig(args.output)
|
plt.savefig(args.output)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in new issue
Block a user