-
Notifications
You must be signed in to change notification settings - Fork 5
/
dalatency.sh
executable file
·54 lines (49 loc) · 1.42 KB
/
dalatency.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Measure latency of Primary DA read.
# VT340+ is very slow printing attribute responses. A fifth of a second!
# Result: Use DSR5 instead which takes 0.02 seconds.
# Output from VT340+
#
# $ ./dalatency.sh
# Measuring latency of ESC [ c
# Latency of Device Attributes is 212,007,764 ns
#
# Measuring latency of ESC [ 6 n
# Latency of Device Status 6 is 48,049,331 ns
#
# Measuring latency of ESC [ 5 n
# Latency of Device Status 5 is 28,955,575 ns
echo "Measuring latency of ESC [ c"
declare -i latency=0
for i in {1..10}; do
start=$(date +%s%N)
# Send Device Attributes request and wait
read -s -d "c" -p $'\e[c'
end=$(date +%s%N)
latency+=$((end-start))
done
latency=latency/10
printf "Latency of %20s is %'12d ns\n" "Device Attributes" $latency
echo
echo "Measuring latency of ESC [ 6 n"
latency=0
for i in {1..10}; do
start=$(date +%s%N)
# Send Device Status Request 6 (cursor position) and wait
read -s -d "R" -p $'\e[6n'
end=$(date +%s%N)
latency+=$((end-start))
done
latency=latency/10
printf "Latency of %20s is %'12d ns\n" "Device Status 6" $latency
echo
echo "Measuring latency of ESC [ 5 n"
latency=0
for i in {1..10}; do
start=$(date +%s%N)
# Send Device Status Request 5 (howyadoin?) and wait
read -s -d "n" -p $'\e[5n'
end=$(date +%s%N)
latency+=$((end-start))
done
latency=latency/10
printf "Latency of %20s is %'12d ns\n" "Device Status 5" $latency