From ee751be1ca1c4bfe92be3aaa7621b84d0c8ac04c Mon Sep 17 00:00:00 2001 From: yanghaitao Date: Mon, 20 Jul 2020 14:29:48 +0800 Subject: [PATCH] fix connector throughput is negative value --- .../minddata/dataset/engine/perf/connector_throughput.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mindspore/ccsrc/minddata/dataset/engine/perf/connector_throughput.cc b/mindspore/ccsrc/minddata/dataset/engine/perf/connector_throughput.cc index b5e2efaf730..693fb2d65de 100644 --- a/mindspore/ccsrc/minddata/dataset/engine/perf/connector_throughput.cc +++ b/mindspore/ccsrc/minddata/dataset/engine/perf/connector_throughput.cc @@ -43,14 +43,17 @@ Status ConnectorThroughput::Sample() { out_buffer_count_row[col] = cur_out_buffer_count; auto sz = timestamps_.size(); cur_time = std::chrono::steady_clock::now(); - auto _dt = std::chrono::duration_cast(timestamps_[0][sz - 1] - timestamps_[0][sz - 2]); - auto dt = std::chrono::duration(_dt).count(); + double dt = 0; + if (sz > 1) { + auto _dt = std::chrono::duration_cast(timestamps_[0][sz - 1] - timestamps_[0][sz - 2]); + dt = std::chrono::duration(_dt).count(); + } auto prev_out_buffer_count = out_buffer_count_table_[col][out_buffer_count_table_.size() - 1]; if (dt != 0) { auto thr = (cur_out_buffer_count - prev_out_buffer_count) / (1000 * dt); throughput_row[col] = thr; } else { - throughput_row[col] = -1; + throughput_row[col] = 0; } col++; }