diff --git a/README.md b/README.md index 2b30aedb782140986a74bd6188b0357e16cf87c0..3951dfc9cfd8968f8efa29f9e61a6fc619ed9d29 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,7 @@ can install some tools that will be used in the next steps: $ sudo apt update $ sudo apt install alsa-utils pulseaudio-utils \ pipewire-jack sndfile-tools \ - psmisc graphviz python3 + psmisc graphviz python3 python3-matplotlib ``` - **alsa-utils** will be used to test sound cards directly using ALSA. - **pulseaudio-utils** gives us `pactl` to check if pipewire is running. @@ -124,6 +124,7 @@ $ sudo apt install alsa-utils pulseaudio-utils \ - **graphviz** provides `dot` which can convert dot files generated by `pw-dot` into png files to represent the PipeWire graph. - **python3** to execute python test scripts. +- **python3-matplotlib** to generate graph from results. If the linux kernel is recent enough, you should have sound cards registrered: diff --git a/scripts/test-case-4-run.py b/scripts/test-case-4-run.py index 4968a9884430c7bc4a06a2b7f512a010a8315d38..bcb4f273888da73fbd2983996cb7ad844cbd04c6 100755 --- a/scripts/test-case-4-run.py +++ b/scripts/test-case-4-run.py @@ -1,5 +1,7 @@ #!/usr/bin/env python3 +from statistics import mean +import matplotlib.pyplot as plt import json import os import signal @@ -78,32 +80,45 @@ if __name__ == "__main__": # my_wav = "/usr/share/sounds/alsa/Front_Center.wav" # duration of 1.428 sec, checked with Audacity # Generate different batches of sndfile-jackplay - for nb_play in list(range(1, 60, 10)): - # To avoid interference from previous run - kill_my_sinks() - time.sleep(2) # Wait 2 sec to be sure all sndfile-jackplay are killed - - print(f"\nStarting {nb_play} sndfile-jackplay") - start_jackplay_loop(my_wav_loop) - for nb_play_i in list(range(2, nb_play)): + my_batches = list(range(1, 60, 10)) + my_results = {new_list: [] for new_list in my_batches} + for nb_play in my_batches: + for run in range(1,11): + # To avoid interference from previous run + kill_my_sinks() + time.sleep(2) # Wait 2 sec to be sure all sndfile-jackplay are killed + + print(f"\nStarting {nb_play} sndfile-jackplay") start_jackplay_loop(my_wav_loop) - time.sleep(2) # Wait 2 sec to be sure all sndfile-jackplay are running - print("Everything is ready for testing!") - print("A new sndfile-jackplay will be run and time required will be measured") - print("Press any key to start the test...") - input() - - t_start = time.time() - start_jackplay(my_wav) - t_end = time.time() - required_time = t_end - t_start + for nb_play_i in list(range(2, nb_play)): + start_jackplay_loop(my_wav_loop) + time.sleep(2) # Wait 2 sec to be sure all sndfile-jackplay are running + print("Everything is ready for testing!") + print("A new sndfile-jackplay will be run and time required will be measured") + #print("Press any key to start the test...") + #input() + + t_start = time.time() + start_jackplay(my_wav) + t_end = time.time() + required_time = t_end - t_start + my_results[nb_play].append(required_time) + + print(f"With {nb_play} running, it tooks {required_time} " + + "to connect and play the sound") - print(f"With {nb_play} running, it tooks {required_time} " + - "to connect and play the sound") - - kill_my_sinks() + kill_my_sinks() - # TODO generate a graph of required_time + # Generate a graph of required_time + x=list(my_results.keys()) + y=[] + for run in my_batches: + y.append(mean(my_results[run])) + plt.plot(x,y) + plt.xlabel('Already running sndfile-jackplay') + plt.ylabel('Time to play a new sound') + plt.title("Test case 4") + plt.savefig('test_case_4_plot.png') # End of test case 4 print("End of test-case 4")