Skip to content

Commit

Permalink
Replace wall clock with monotonic clock
Browse files Browse the repository at this point in the history
  • Loading branch information
SamanKazemkhani committed May 2, 2024
1 parent 664e6c3 commit 1375d88
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/headless.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ int main(int argc, char *argv[])
std::uniform_real_distribution<float> acc_gen(-3.0,2.0);
std::uniform_real_distribution<float> steer_gen(-0.7,0.7);

auto start = std::chrono::system_clock::now();
auto action_printer = mgr.actionTensor().makePrinter();
auto model_printer = mgr.bicycleModelTensor().makePrinter();
auto self_printer = mgr.selfObservationTensor().makePrinter();
Expand Down Expand Up @@ -132,6 +131,7 @@ int main(int argc, char *argv[])
mgr.getShapeTensorFromDeviceMemory(exec_mode, num_worlds);


const auto start = std::chrono::steady_clock::now();
for (CountT i = 0; i < (CountT)num_steps; i++) {
if (rand_actions) {
for (CountT j = 0; j < (CountT)num_worlds; j++) {
Expand All @@ -153,9 +153,8 @@ int main(int argc, char *argv[])
mgr.step();
printObs();
}

auto end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed = end - start;
const auto end = std::chrono::steady_clock::now();
const std::chrono::duration<double> elapsed= end - start;

float fps = (double)num_steps * (double)num_worlds / elapsed.count();
printf("FPS %f\n", fps);
Expand Down

0 comments on commit 1375d88

Please sign in to comment.