Skip to content

Commit

Permalink
[core,pr] tidy printing
Browse files Browse the repository at this point in the history
  • Loading branch information
sbeamer committed Sep 28, 2023
1 parent 0fb6a47 commit d48e9b5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/pr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pvector<ScoreT> PageRankPullGS(const Graph &g, int max_iters,
error += fabs(scores[u] - old_score);
outgoing_contrib[u] = scores[u] / g.out_degree(u);
}
printf(" %2d %lf\n", iter, error);
PrintStep(iter, error);
if (error < epsilon)
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/pr_spmv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pvector<ScoreT> PageRankPull(const Graph &g, int max_iters,
scores[u] = base_score + kDamp * incoming_total;
error += fabs(scores[u] - old_score);
}
printf(" %2d %lf\n", iter, error);
PrintStep(iter, error);
if (error < epsilon)
break;
}
Expand Down
11 changes: 4 additions & 7 deletions src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,17 @@ void PrintStep(const std::string &s, int64_t count) {
printf("%-14s%14" PRId64 "\n", (s + ":").c_str(), count);
}

void PrintStep(int step, double seconds, int64_t count = -1) {
if (count != -1)
printf("%5d%11" PRId64 " %10.5lf\n", step, count, seconds);
else
printf("%5d%23.5lf\n", step, seconds);
}

void PrintStep(const std::string &s, double seconds, int64_t count = -1) {
if (count != -1)
printf("%5s%11" PRId64 " %10.5lf\n", s.c_str(), count, seconds);
else
printf("%5s%23.5lf\n", s.c_str(), seconds);
}

void PrintStep(int step, double seconds, int64_t count = -1) {
PrintStep(std::to_string(step), seconds, count);
}

// Runs op and prints the time it took to execute labelled by label
#define TIME_PRINT(label, op) { \
Timer t_; \
Expand Down

0 comments on commit d48e9b5

Please sign in to comment.