Skip to content

Commit 044d2e2

Browse files
committed
update test method
1 parent 92cbaa4 commit 044d2e2

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

paddle/fluid/operators/reader/ctr_reader.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ void ReadThread(const std::vector<std::string>& file_list,
222222

223223
if (i != 0 && i % 100 == 0) {
224224
uint64_t t1 = GetTimeInSec();
225-
float line_per_s = 100 * batch_size / static_cast<int>(t1 - t0);
225+
float line_per_s = 100 * batch_size * 1000000 / (t1 - t0);
226226
VLOG(3) << "[" << thread_id << "]"
227227
<< " line_per_second = " << line_per_s;
228228
t0 = t1;

paddle/fluid/operators/reader/ctr_reader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ inline uint64_t GetTimeInSec() {
4343
using clock = std::conditional<std::chrono::high_resolution_clock::is_steady,
4444
std::chrono::high_resolution_clock,
4545
std::chrono::steady_clock>::type;
46-
return std::chrono::duration_cast<std::chrono::seconds>(
46+
return std::chrono::duration_cast<std::chrono::microseconds>(
4747
clock::now().time_since_epoch())
4848
.count();
4949
}

paddle/fluid/operators/reader/ctr_reader_test.cc

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ TEST(CTR_READER, read_data) {
3535
std::shared_ptr<LoDTensorBlockingQueue> queue = queue_holder.GetQueue();
3636

3737
int batch_size = 10;
38-
int thread_num = 4;
38+
int thread_num = 3;
3939
std::vector<std::string> slots = {
4040
"6002", "6003", "6004", "6005", "6006", "6007", "6008", "6009", "6010",
4141
"6011", "6012", "6013", "6014", "6015", "6016", "6017", "6018", "6019",
@@ -119,12 +119,15 @@ TEST(CTR_READER, read_data) {
119119

120120
std::cout << "start to reader data" << std::endl;
121121
std::vector<LoDTensor> out;
122-
int read_batch = 1000;
122+
int read_batch = 10000;
123123
uint64_t t0 = GetTimeInSec();
124124
for (int i = 0; i < read_batch; ++i) {
125125
reader.ReadNext(&out);
126+
if (i != 0 && i % 100 == 0) {
127+
uint64_t t1 = GetTimeInSec();
128+
float line_per_s = 100 * batch_size * 1000000 / (t1 - t0);
129+
VLOG(3) << "line_per_second = " << line_per_s;
130+
t0 = GetTimeInSec();
131+
}
126132
}
127-
uint64_t t1 = GetTimeInSec();
128-
float line_per_s = read_batch * batch_size / static_cast<int>(t1 - t0);
129-
VLOG(3) << "line_per_second = " << line_per_s;
130133
}

0 commit comments

Comments
 (0)