!3232 fix connector throughput value is negative

Merge pull request !3232 from yanghaitao/yht_profiling_throughtout
This commit is contained in:
mindspore-ci-bot 2020-07-21 17:00:09 +08:00 committed by Gitee
commit b50a0d1a08
1 changed files with 6 additions and 3 deletions

View File

@ -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<std::chrono::microseconds>(timestamps_[0][sz - 1] - timestamps_[0][sz - 2]);
auto dt = std::chrono::duration<double>(_dt).count();
double dt = 0;
if (sz > 1) {
auto _dt = std::chrono::duration_cast<std::chrono::microseconds>(timestamps_[0][sz - 1] - timestamps_[0][sz - 2]);
dt = std::chrono::duration<double>(_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++;
}