Skip to content

Commit

Permalink
update logging
Browse files Browse the repository at this point in the history
  • Loading branch information
1a1a11a committed Oct 15, 2023
1 parent 051f89a commit 4a9b24c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
4 changes: 2 additions & 2 deletions libCacheSim/traceAnalyzer/utils/include/utilsPrint.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ static inline void print_progress(double perc) {
return;
}
if (last_perc != 0)
fprintf(stderr, "\033[A\033[2K\r");
fprintf(stderr, "%.2f%%\n", perc);
fprintf(stdout, "\033[A\033[2K\r");
fprintf(stdout, "%.2f%%\n", perc);
last_perc = perc;
last_print_time = cur_time;
}
Expand Down
4 changes: 2 additions & 2 deletions libCacheSim/utils/logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ void print_progress(double perc) {
sleep(2);
return;
}
if (last_perc != 0) fprintf(stderr, "\033[A\033[2K\r");
fprintf(stderr, "%.2f%%...\n", perc);
if (last_perc != 0) fprintf(stdout, "\033[A\033[2K\r");
fprintf(stdout, "%.2f%%...\n", perc);
last_perc = perc;
last_print_time = cur_time;
}
8 changes: 7 additions & 1 deletion scripts/plot_mrc_size.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,16 @@ def run_cachesim_size(
logger.debug('running "{}"'.format(" ".join(run_args)))

p = subprocess.run(run_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if p.returncode != 0:
logger.warning("cachesim may have crashed with segfault")

stderr_str = p.stderr.decode("utf-8")
if stderr_str != "":
logger.warning(stderr_str)

stdout_str = p.stdout.decode("utf-8")
for line in stdout_str.split("\n"):
logger.info(line)
logger.info("cachesim log: " + line)

if "[INFO]" in line[:16]:
continue
Expand Down Expand Up @@ -251,6 +253,10 @@ def run():
ap.num_thread,
)

if len(mrc_dict) == 0:
logger.error("fail to compute mrc")
sys.exit(1)

with open("/tmp/{}.mrc.pickle".format(dataname), "wb") as f:
pickle.dump(mrc_dict, f)

Expand Down
8 changes: 7 additions & 1 deletion scripts/plot_mrc_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,16 @@ def run_cachesim_time(
logger.debug('running "{}"'.format(" ".join(run_args)))

p = subprocess.run(run_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if p.returncode != 0:
logger.warning("cachesim may have crashed with segfault")

stderr_str = p.stderr.decode("utf-8")
if stderr_str != "":
logger.warning(stderr_str)

stdout_str = p.stdout.decode("utf-8")
for line in stdout_str.split("\n"):
logger.debug(line)
logger.debug("cachesim log: " + line)

if "[INFO]" in line[:16]:
m = re.search(REGEX, line)
Expand Down Expand Up @@ -217,4 +219,8 @@ def run():
ap.num_thread,
)

if len(mrc_dict) == 0:
logger.error("fail to compute mrc")
sys.exit(1)

plot_mrc_time(mrc_dict, "{}_{}".format(dataname, ap.size))

0 comments on commit 4a9b24c

Please sign in to comment.