| OLD | NEW |
| 1 #!/bin/bash | 1 #!/bin/bash |
| 2 | 2 |
| 3 # Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 3 # Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
| 4 # | 4 # |
| 5 # Use of this source code is governed by a BSD-style license | 5 # Use of this source code is governed by a BSD-style license |
| 6 # that can be found in the LICENSE file in the root of the source | 6 # that can be found in the LICENSE file in the root of the source |
| 7 # tree. An additional intellectual property rights grant can be found | 7 # tree. An additional intellectual property rights grant can be found |
| 8 # in the file PATENTS. All contributing project authors may | 8 # in the file PATENTS. All contributing project authors may |
| 9 # be found in the AUTHORS file in the root of the source tree. | 9 # be found in the AUTHORS file in the root of the source tree. |
| 10 | 10 |
| 11 # To set up in e.g. Eclipse, run a separate shell and pipe the output from the | 11 # To set up in e.g. Eclipse, run a separate shell and pipe the output from the |
| 12 # test into this script. | 12 # test into this script. |
| 13 # | 13 # |
| 14 # In Eclipse, that amounts to creating a Run Configuration which starts | 14 # In Eclipse, that amounts to creating a Run Configuration which starts |
| 15 # "/bin/bash" with the arguments "-c [trunk_path]/out/Debug/modules_unittests | 15 # "/bin/bash" with the arguments "-c [trunk_path]/out/Debug/modules_unittests |
| 16 # --gtest_filter=*BweTest* | [trunk_path]/webrtc/modules/ | 16 # --gtest_filter=*BweTest* | [trunk_path]/webrtc/modules/ |
| 17 # remote_bitrate_estimator/bwe_plot. | 17 # remote_bitrate_estimator/test/plot_dynamics.sh |
| 18 | 18 |
| 19 # bwe_plot.sh supports multiple figures (windows), the figure is specified as an | 19 # This script supports multiple figures (windows), the figure is specified as an |
| 20 # identifier at the first argument after the PLOT command. Each figure has a | 20 # identifier at the first argument after the PLOT command. Each figure has a |
| 21 # single y axis and a dual y axis mode. If any line specifies an axis by ending | 21 # single y axis and a dual y axis mode. If any line specifies an axis by ending |
| 22 # with "#<axis number (1 or 2)>" two y axis will be used, the first will be | 22 # with "#<axis number (1 or 2)>" two y axis will be used, the first will be |
| 23 # assumed to represent bitrate (in kbps) and the second will be assumed to | 23 # assumed to represent bitrate (in kbps) and the second will be assumed to |
| 24 # represent time deltas (in ms). | 24 # represent time deltas (in ms). |
| 25 | 25 |
| 26 log=$(</dev/stdin) | 26 log=$(</dev/stdin) |
| 27 | 27 |
| 28 # Plot dynamics. |
| 28 function gen_gnuplot_input { | 29 function gen_gnuplot_input { |
| 29 colors=(a7001f 0a60c2 b2582b 21a66c d6604d 4393c3 f4a582 92c5de edcbb7 b1c5d0) | 30 colors=(a7001f 0a60c2 b2582b 21a66c d6604d 4393c3 f4a582 92c5de edcbb7 b1c5d0) |
| 30 plots=$(echo "$log" | grep "^PLOT") | 31 plots=$(echo "$log" | grep "^PLOT") |
| 31 figures=($(echo "$plots" | cut -f 2 | sort | uniq)) | 32 figures=($(echo "$plots" | cut -f 2 | sort | uniq)) |
| 32 | 33 |
| 33 for figure in "${figures[@]}" ; do | 34 for figure in "${figures[@]}" ; do |
| 34 data_sets=$(echo "$plots" | grep "^PLOT.$figure" | cut -f 3 | sort | uniq) | 35 data_sets=$(echo "$plots" | grep "^PLOT.$figure" | cut -f 3 | sort | uniq) |
| 35 linetypes=($(echo "$data_sets" | grep "#" | cut -d '#' -f 2 | \ | 36 linetypes=($(echo "$data_sets" | grep "#" | cut -d '#' -f 2 | \ |
| 36 cut -d ' ' -f 1)) | 37 cut -d ' ' -f 1)) |
| 37 echo -n "reset; " | 38 echo "reset; " |
| 38 echo -n "set terminal wxt $figure size 1440,900 font \"Arial,9\"; " | 39 echo "set terminal wxt $figure size 1440,900 font \"Arial,9\"; " |
| 39 echo -n "set xlabel \"Seconds\"; " | 40 echo "set xlabel \"Seconds\"; " |
| 40 if (( "${#linetypes[@]}" > "0" )); then | 41 if (( "${#linetypes[@]}" > "0" )); then |
| 41 echo -n "set ylabel 'bitrate (kbps)';" | 42 echo "set ylabel 'bitrate (kbps)';" |
| 42 echo -n "set ytics nomirror;" | 43 echo "set ytics nomirror;" |
| 43 echo -n "set y2label 'time delta (ms)';" | 44 echo "set y2label 'time delta (ms)';" |
| 44 echo -n "set y2tics nomirror;" | 45 echo "set y2tics nomirror;" |
| 45 fi | 46 fi |
| 46 echo -n "plot " | 47 echo -n "plot " |
| 47 i=0 | 48 i=0 |
| 48 for set in $data_sets ; do | 49 for set in $data_sets ; do |
| 49 (( i++ )) && echo -n "," | 50 (( i++ )) && echo -n "," |
| 50 echo -n "'-' with " | 51 echo -n "'-' with " |
| 51 echo -n "linespoints " | 52 echo -n "linespoints " |
| 52 echo -n "ps 0.5 " | 53 echo -n "ps 0.5 " |
| 53 echo -n "lc rgbcolor \"#${colors[$(($i % 10))]}\" " | 54 echo -n "lc rgbcolor \"#${colors[$(($i % 10))]}\" " |
| 54 if (( "${#linetypes[@]}" > "0" )); then | 55 if (( "${#linetypes[@]}" > "0" )); then |
| 55 if (( "$i" <= "${#linetypes[@]}" )); then | 56 if (( "$i" <= "${#linetypes[@]}" )); then |
| 56 echo -n "axes x1y${linetypes[$i - 1]} " | 57 echo -n "axes x1y${linetypes[$i - 1]} " |
| 57 else | 58 else |
| 58 # If no line type is specified, but line types are used, we will | 59 # If no line type is specified, but line types are used, we will |
| 59 # default to the bitrate axis. | 60 # default to the bitrate axis. |
| 60 echo -n "axes x1y1 " | 61 echo -n "axes x1y1 " |
| 61 fi | 62 fi |
| 62 fi | 63 fi |
| 63 echo -n "title \"$set\" " | 64 echo -n "title \"$set\" " |
| 64 done | 65 done |
| 65 echo | 66 echo |
| 66 for set in $data_sets ; do | 67 for set in $data_sets ; do |
| 67 echo "$log" | grep "^PLOT.$figure.$set" | cut -f 4,5 | 68 echo "$log" | grep "^PLOT.$figure.$set" | cut -f 4,5 |
| 68 echo "e" | 69 echo "e" |
| 69 done | 70 done |
| 70 done | 71 done |
| 71 } | 72 } |
| 72 | |
| 73 gen_gnuplot_input | gnuplot -persist | 73 gen_gnuplot_input | gnuplot -persist |
| OLD | NEW |