Skip to content

Commit

Permalink
Fix the cpplint errors for benchmark Timer
Browse files Browse the repository at this point in the history
  • Loading branch information
kloudkl committed Mar 4, 2014
1 parent 342a911 commit cc509a9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/caffe/test/test_benchmark.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2014 kloud@github

#include <unistd.h> // for usleep
#include <unistd.h> // for usleep
#include <cuda_runtime.h>
#include <gtest/gtest.h>

Expand Down
3 changes: 2 additions & 1 deletion src/caffe/util/benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ float Timer::MilliSeconds() {
Stop();
}
if (Caffe::mode() == Caffe::GPU) {
CUDA_CHECK(cudaEventElapsedTime(&elapsed_milliseconds_, start_gpu_, stop_gpu_));
CUDA_CHECK(cudaEventElapsedTime(&elapsed_milliseconds_, start_gpu_,
stop_gpu_));
} else {
elapsed_milliseconds_ = (stop_cpu_ - start_cpu_).total_milliseconds();
}
Expand Down
21 changes: 13 additions & 8 deletions tools/net_speed_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#include <cstring>
#include <ctime>
#include <string>
#include <vector>

#include "caffe/blob.hpp"
#include "caffe/common.hpp"
Expand All @@ -16,14 +18,13 @@
#include "caffe/util/io.hpp"
#include "caffe/solver.hpp"

using namespace caffe;
using namespace caffe; // NOLINT(build/namespaces)

int main(int argc, char** argv) {

int total_iter = 50;

if (argc < 2) {
LOG(ERROR) << "net_speed_benchmark net_proto [iterations=50] [CPU/GPU] [Device_id=0]";
LOG(ERROR) << "net_speed_benchmark net_proto [iterations=50]"
" [CPU/GPU] [Device_id=0]";
return 0;
}

Expand Down Expand Up @@ -76,9 +77,11 @@ int main(int argc, char** argv) {
for (int j = 0; j < total_iter; ++j) {
layers[i]->Forward(bottom_vecs[i], &top_vecs[i]);
}
LOG(ERROR) << layername << "\tforward: " << timer.MilliSeconds() << " milli seconds.";
LOG(ERROR) << layername << "\tforward: " << timer.MilliSeconds() <<
" milli seconds.";
}
LOG(ERROR) << "Forward pass: " << forward_timer.MilliSeconds() << " milli seconds.";
LOG(ERROR) << "Forward pass: " << forward_timer.MilliSeconds() <<
" milli seconds.";
Timer backward_timer;
backward_timer.Start();
for (int i = layers.size() - 1; i >= 0; --i) {
Expand All @@ -90,8 +93,10 @@ int main(int argc, char** argv) {
LOG(ERROR) << layername << "\tbackward: "
<< timer.MilliSeconds() << " milli seconds.";
}
LOG(ERROR) << "Backward pass: " << backward_timer.MilliSeconds() << " milli seconds.";
LOG(ERROR) << "Total Time: " << total_timer.MilliSeconds() << " milli seconds.";
LOG(ERROR) << "Backward pass: " << backward_timer.MilliSeconds() <<
" milli seconds.";
LOG(ERROR) << "Total Time: " << total_timer.MilliSeconds() <<
" milli seconds.";
LOG(ERROR) << "*** Benchmark ends ***";
return 0;
}

0 comments on commit cc509a9

Please sign in to comment.