Skip to content
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

xtest: stats: report heap fragmentation metric #781

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions host/xtest/stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <errno.h>
#include <fnmatch.h>
#include <inttypes.h>
#include <math.h>
#include <pta_stats.h>
#include <stdbool.h>
#include <stdint.h>
Expand Down Expand Up @@ -154,6 +155,15 @@ static int stat_alloc(int argc, char *argv[])
stats[n].desc);
printf("Bytes allocated: %"PRId32"\n",
stats[n].allocated);
if (stats[n].free2_sum) {
double free2_sum = stats[n].free2_sum;
double free_sum = stats[n].size - stats[n].allocated;
double free_quote = sqrt(free2_sum) / free_sum;
double fragmentation = 1.0 - free_quote;

printf("Fragmentation: %u %%\n",
(unsigned int)(fragmentation * 100.0));
}
printf("Max bytes allocated: %"PRId32"\n",
stats[n].max_allocated);
printf("Size of pool: %"PRId32"\n",
Expand Down
2 changes: 1 addition & 1 deletion host/xtest/xtest_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ int main(int argc, char *argv[])
ret = Do_ADBG_AppendToSuite(&all, &ADBG_Suite_ffa_spmc);
#endif
else {
fprintf(stderr, "Unkown test suite: %s\n", token);
fprintf(stderr, "Unknown test suite: %s\n", token);
ret = -1;
}
if (ret < 0)
Expand Down
Loading