You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

rdr.cc 2.7 kB

5 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /**
  2. * Copyright 2021 Huawei Technologies Co., Ltd
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #include "minddata/dataset/util/rdr.h"
  17. #include "minddata/dataset/util/log_adapter.h"
  18. namespace mindspore {
  19. namespace dataset {
  20. const int32_t kMdRdrRecordLimit = 10;
  21. std::string MDChannelInfo::ToString() {
  22. std::ostringstream ss;
  23. {
  24. std::unique_lock<std::mutex> lock(mutex_);
  25. ss << "preprocess_batch: " << preprocess_batch_ << "; ";
  26. ss << "batch_queue: ";
  27. for (uint32_t i = 0; i < batch_queue_.size(); i++) {
  28. ss << batch_queue_.at(i);
  29. if (i < batch_queue_.size() - 1) {
  30. ss << ", ";
  31. }
  32. }
  33. ss << "; push_start_time: ";
  34. for (uint32_t i = 0; i < push_start_time_.size(); i++) {
  35. ss << push_start_time_.at(i);
  36. if (i < push_start_time_.size() - 1) {
  37. ss << ", ";
  38. }
  39. }
  40. ss << "; push_end_time: ";
  41. for (uint32_t i = 0; i < push_end_time_.size(); i++) {
  42. ss << push_end_time_.at(i);
  43. if (i < push_end_time_.size() - 1) {
  44. ss << ", ";
  45. }
  46. }
  47. ss << ".";
  48. }
  49. return ss.str();
  50. }
  51. Status MDChannelInfo::RecordBatchQueue(int64_t batch_queue_size) {
  52. {
  53. std::unique_lock<std::mutex> lock(mutex_);
  54. if (batch_queue_.size() == kMdRdrRecordLimit) {
  55. batch_queue_.pop_front();
  56. }
  57. batch_queue_.push_back(batch_queue_size);
  58. }
  59. return Status::OK();
  60. }
  61. Status MDChannelInfo::RecordPreprocessBatch(int64_t preprocess_batch) {
  62. {
  63. std::unique_lock<std::mutex> lock(mutex_);
  64. preprocess_batch_ = preprocess_batch;
  65. }
  66. return Status::OK();
  67. }
  68. Status MDChannelInfo::RecordPushStartTime() {
  69. {
  70. std::unique_lock<std::mutex> lock(mutex_);
  71. if (push_start_time_.size() == kMdRdrRecordLimit) {
  72. push_start_time_.pop_front();
  73. }
  74. push_start_time_.push_back(GetTimeString());
  75. }
  76. return Status::OK();
  77. }
  78. Status MDChannelInfo::RecordPushEndTime() {
  79. {
  80. std::unique_lock<std::mutex> lock(mutex_);
  81. if (push_end_time_.size() == kMdRdrRecordLimit) {
  82. push_end_time_.pop_front();
  83. }
  84. push_end_time_.push_back(GetTimeString());
  85. }
  86. return Status::OK();
  87. }
  88. } // namespace dataset
  89. } // namespace mindspore