Skip to content
Snippets Groups Projects
Commit 52b0fb3a authored by Dylan Aïssi's avatar Dylan Aïssi
Browse files

Finalize test-case-4-run.py


Signed-off-by: default avatarDylan Aïssi <dylan.aissi@collabora.com>
parent f9b9ffd3
Branches main
No related merge requests found
Pipeline #625283 passed
......@@ -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:
......
#!/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")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment