mirror of
https://github.com/larsimmisch/pyalsaaudio.git
synced 2026-04-29 05:34:50 +00:00
chore: move examples to dedicated directory
This commit is contained in:
committed by
Lars Immisch
parent
0b3f1f41c7
commit
df5c2f4685
25
examples/play_rusage.py
Normal file
25
examples/play_rusage.py
Normal file
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# Contributed by Stein Magnus Jodal
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import resource
|
||||
import time
|
||||
|
||||
import alsaaudio
|
||||
|
||||
seconds = 0
|
||||
max_rss = 0
|
||||
device = alsaaudio.PCM()
|
||||
|
||||
while True:
|
||||
device.write(b'\x00' * 44100)
|
||||
time.sleep(1)
|
||||
seconds += 1
|
||||
if seconds % 10 == 0:
|
||||
prev_rss = max_rss
|
||||
max_rss = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
|
||||
diff_rss = max_rss - prev_rss
|
||||
print('After %ds: max RSS %d kB, increased %d kB' % (
|
||||
seconds, max_rss, diff_rss))
|
||||
Reference in New Issue
Block a user