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++; }