-
Notifications
You must be signed in to change notification settings - Fork 683
Eliminate code duplication in memory statistics printing #841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Eliminate code duplication in memory statistics printing #841
Conversation
stats.peak_pools_count, | ||
stats.peak_allocated_chunks); | ||
#endif /* MEM_STATS */ | ||
mem_stats_print (); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@akiss77, for me it seems better to put mem_stats_print
under #ifdef MEM_STATS
, as without the define the call is no-op.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ruben-ayrapetyan I've been considering that as well. The reason why I proposed the above is that it remained semantically equivalent with the original version, which also left the call to mem_heap_print
unguarded. Even in mem_heap_print
, there are quite some code lines which are always compiled, and only a final portion is ifdef'd by MEM_STATS
. If we choose to ifdef the call here, then maybe we should consider putting much more code under ifdef guards,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@akiss77, I see. Thank you for your explanation.
The part of mem_heap_print
that is not currently guarded by MEM_STATS
, is not executed during the call, because the corresponding arguments are set to false
, and only dump_stats
argument is set to true
.
So, maybe, its better to extract part of mem_heap_print
that outputs statistics to another routine like mem_heap_print_stats
, guard it with MEM_STATS
, and call it from mem_heap_print
and mem_stats_print
. In the case, mem_stats_print
could be guarded by #ifdef
around the function, not inside.
What do you think about this?
1145288
to
c0f0b0a
Compare
@ruben-ayrapetyan I've updated the patch. I guess I got it according to your feedback. The only change I made is that I used the name |
JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
c0f0b0a
to
7e36040
Compare
LGTM |
Landed (196e819) |
JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu