T0=$(date +%N)
time echo $NEW_VAL | tee $SYSFILE
T1=$(date +%N)
echo "Total time (millis): $(((T1 - T0)/1000))"
Gives the following:
real 0m0.002s
user 0m0.002s
sys 0m0.001s
Total time (millis): 3502
In other words, the write to sysfs returns in 2ms (and indeed, brightness changes instantly), but it takes 3502ms for control to get back to the prompt.
During that time, the system seems to hang, but keypresses are collected: they are all echoed to the terminal right after the command returns. So the question then is: where are the 3 seconds spent?
I'm happy to experiment if someone has instructions.
Adding some more information. Running the following as root in a gnome terminal:
SYSFILE= /sys/class/ backlight/ intel_backlight /brightness VAL=$(( OLD_VAL + 100))
OLD_VAL=$(cat $SYSFILE)
NEW_
T0=$(date +%N)
time echo $NEW_VAL | tee $SYSFILE
T1=$(date +%N)
echo "Total time (millis): $(((T1 - T0)/1000))"
Gives the following:
real 0m0.002s
user 0m0.002s
sys 0m0.001s
Total time (millis): 3502
In other words, the write to sysfs returns in 2ms (and indeed, brightness changes instantly), but it takes 3502ms for control to get back to the prompt.
During that time, the system seems to hang, but keypresses are collected: they are all echoed to the terminal right after the command returns. So the question then is: where are the 3 seconds spent?
I'm happy to experiment if someone has instructions.