diff options
author | Gerald Combs <gerald@wireshark.org> | 2013-09-06 19:07:57 +0000 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2013-09-06 19:07:57 +0000 |
commit | 297d1994f8b1ad54c705af40d0976c6b5e5b60df (patch) | |
tree | c7c6934bb6e16f4d91277fb139b9e737db7803d5 /ui/qt/tcp_stream_dialog.cpp | |
parent | 52c9e574743e6ef49c0ba36dda48e8f34298bbf5 (diff) |
Switch from a 20 segment moving average to a 1 second MA. Add a #define
to allow switching back to the old behavior.
Note that goToPacket can jump to the wrong packet if we have a display
filter applied.
svn path=/trunk/; revision=51801
Diffstat (limited to 'ui/qt/tcp_stream_dialog.cpp')
-rw-r--r-- | ui/qt/tcp_stream_dialog.cpp | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/ui/qt/tcp_stream_dialog.cpp b/ui/qt/tcp_stream_dialog.cpp index 7cce852738..3d153e9caa 100644 --- a/ui/qt/tcp_stream_dialog.cpp +++ b/ui/qt/tcp_stream_dialog.cpp @@ -37,7 +37,13 @@ #include <QDebug> +// The GTK+ version computes a 20 (or 21!) segment moving average. Comment +// out the line below to use that. By default we use a 1 second MA. +#define MA_1_SECOND + +#ifndef MA_1_SECOND const int moving_avg_period_ = 20; +#endif const QRgb graph_color_1 = tango_sky_blue_5; const QRgb graph_color_2 = tango_butter_6; @@ -318,9 +324,12 @@ void TCPStreamDialog::initializeStevens() void TCPStreamDialog::initializeThroughput() { - QString dlg_title = QString(tr("Throughput")) - + streamDescription() - + QString(tr(" (%1 segment MA)")).arg(moving_avg_period_); + QString dlg_title = QString(tr("Throughput")) + streamDescription(); +#ifdef MA_1_SECOND + dlg_title.append(tr(" (1 s MA)")); +#else + dlg_title.append(QString(tr(" (%1 segment MA)")).arg(moving_avg_period_)); +#endif setWindowTitle(dlg_title); title_->setText(dlg_title); @@ -337,7 +346,10 @@ void TCPStreamDialog::initializeThroughput() QVector<double> rel_time, seg_len, tput; struct segment *oldest_seg = graph_.segments; - int i = 1, sum = 0; +#ifndef MA_1_SECOND + int i = 1; +#endif + int sum = 0; // Financial charts don't show MA data until a full period has elapsed. // The Rosetta Code MA examples start spitting out values immediately. // For now use not-really-correct initial values just to keep our vector @@ -345,12 +357,18 @@ void TCPStreamDialog::initializeThroughput() for (struct segment *seg = graph_.segments->next; seg != NULL; seg = seg->next) { double rt_val = seg->rel_secs + seg->rel_usecs / 1000000.0; - // XXX Skip zero-length segments? +#ifdef MA_1_SECOND + while (rt_val - (oldest_seg->rel_secs + oldest_seg->rel_usecs / 1000000.0) > 1.0) { + oldest_seg = oldest_seg->next; + sum -= oldest_seg->th_seglen; + } +#else if (i > moving_avg_period_) { oldest_seg = oldest_seg->next; sum -= oldest_seg->th_seglen; } i++; +#endif double dtime = rt_val - (oldest_seg->rel_secs + oldest_seg->rel_usecs / 1000000.0); double av_tput; |