Earlier today (sorry - yesterday!) at the audio mini-summit I promised to release a tool that I used for evaluating sound server energy efficiency. The tool is a shell script, which is attached, together with an example report. It needs to be run as root (in a throwaway VM, if you need), with one argument: the name of a directory to be created and populated with various files. The script needs the "debootstrap" program to be installed.
The script will populate the directory with a Debian Jessie amd64 installation, compile CRAS there, and pack everything into an initramfs file that can be used for evaluation. It will produce two files as the main result: vmlinuz and initramfs.img, near the directory that it creates.
The initramfs will play a sound file in a loop (please use headphones, so that your laptop does not annoy anyone) and log the laptop battery energy or charge. If it drops below 75% of the initial value, the experiment is terminated, the log is saved to the disk, and the laptop is powered off.
You can add this to your boot loader. Example for extlinux:
LABEL battery-pulse7 MENU LABEL Battery Benchmark (pulseaudio 7) LINUX /boot/battery-benchmark/vmlinuz INITRD /boot/battery-benchmark/initramfs.img APPEND quiet root=ram save=/dev/md126p1 test_case=pulse pa_version=7 latency_msec=28 dobenchmark
Here is the meaning of the arguments:
quiet: don't print verbose messages to the console root=ram: use ramfs (not tmpfs) for the extracted initramfs save=/dev/...: save the log to this block device at the end. The /battery-reports directory will be created, and the log will be placed there. FAT32, NTFS and EXT4 filesystems are supported. test_case=pulse|alsa|cras: what we want to test. alsa means raw hw device. pa_version=5|6|7: version of PulseAudio to test latency_msec: buffer size or its equivalent, in milliseconds cras_output: the correct output node for CRAS. Usually 5:0 (the default) or 6:0, please see cras_test_client --dump_server_info resampler: force a given resampler for PulseAudio (if not given, no resampler is used) dobenchmark: dpms-blank the screen and perform the measurement automatically
To replicate the results in my presentation, it is sufficient to obtain logs for all three versions of PulseAudio, as well as ALSA and CRAS, for the following latency_msec values: 7, 28, 448. Please send any reports created by this tool to me directly, and mention the laptop model.
A big "thanks" goes to Felipe Sateler for providing Debian packages of PulseAudio that are mostly compatible with Debian Jessie.