-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf tools: Add unit_number__scnprintf function
Add unit_number__scnprintf function to display size units and use it in -m option info message. Before: $ perf record -m 10M ls rounding mmap pages size to 16777216 bytes (4096 pages) ... After: $ perf record -m 10M ls rounding mmap pages size to 16M (4096 pages) ... Signed-off-by: Jiri Olsa <jolsa@kernel.org> Cc: David Ahern <dsahern@gmail.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/r/1483955520-29063-2-git-send-email-jolsa@kernel.org [ Rename it to unit_number__scnprintf for consistency ] Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
- Loading branch information
Jiri Olsa
authored and
Arnaldo Carvalho de Melo
committed
Jan 11, 2017
1 parent
e978be9
commit 9808143
Showing
7 changed files
with
63 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include <linux/compiler.h> | ||
#include <linux/types.h> | ||
#include "tests.h" | ||
#include "util.h" | ||
#include "debug.h" | ||
|
||
int test__unit_number__scnprint(int subtest __maybe_unused) | ||
{ | ||
struct { | ||
u64 n; | ||
const char *str; | ||
} test[] = { | ||
{ 1, "1B" }, | ||
{ 10*1024, "10K" }, | ||
{ 20*1024*1024, "20M" }, | ||
{ 30*1024*1024*1024ULL, "30G" }, | ||
{ 0, "0B" }, | ||
{ 0, NULL }, | ||
}; | ||
unsigned i = 0; | ||
|
||
while (test[i].str) { | ||
char buf[100]; | ||
|
||
unit_number__scnprintf(buf, sizeof(buf), test[i].n); | ||
|
||
pr_debug("n %" PRIu64 ", str '%s', buf '%s'\n", | ||
test[i].n, test[i].str, buf); | ||
|
||
if (strcmp(test[i].str, buf)) | ||
return TEST_FAIL; | ||
|
||
i++; | ||
} | ||
|
||
return TEST_OK; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters