[tip:perf/core] perf timechart: Use NSEC_PER_U?SEC

2016-08-24 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  af4b2c972a5fc9358486d946d15f32510534ccbf
Gitweb: http://git.kernel.org/tip/af4b2c972a5fc9358486d946d15f32510534ccbf
Author: Arnaldo Carvalho de Melo 
AuthorDate: Mon, 8 Aug 2016 12:45:58 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 23 Aug 2016 15:37:33 -0300

perf timechart: Use NSEC_PER_U?SEC

Following kernel practices, using linux/time64.h

Cc: Adrian Hunter 
Cc: Arjan van de Ven 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Stanislav Fomichev 
Cc: Steven Rostedt 
Cc: Wang Nan 
Link: http://lkml.kernel.org/n/tip-5l1md8lsdhfnrlsqyejzo...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-timechart.c | 13 +++--
 tools/perf/util/svghelper.c| 11 ++-
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c
index 733a554..e7eaa29 100644
--- a/tools/perf/builtin-timechart.c
+++ b/tools/perf/builtin-timechart.c
@@ -24,6 +24,7 @@
 #include "util/evlist.h"
 #include "util/evsel.h"
 #include 
+#include 
 #include "util/symbol.h"
 #include "util/callchain.h"
 #include "util/strlist.h"
@@ -1288,9 +1289,9 @@ static void draw_process_bars(struct timechart *tchart)
if (c->comm) {
char comm[256];
if (c->total_time > 50) /* 5 seconds */
-   sprintf(comm, "%s:%i (%2.2fs)", 
c->comm, p->pid, c->total_time / 10.0);
+   sprintf(comm, "%s:%i (%2.2fs)", 
c->comm, p->pid, c->total_time / (double)NSEC_PER_SEC);
else
-   sprintf(comm, "%s:%i (%3.1fms)", 
c->comm, p->pid, c->total_time / 100.0);
+   sprintf(comm, "%s:%i (%3.1fms)", 
c->comm, p->pid, c->total_time / (double)NSEC_PER_MSEC);
 
svg_text(Y, c->start_time, comm);
}
@@ -1637,7 +1638,7 @@ static int __cmd_timechart(struct timechart *tchart, 
const char *output_name)
write_svg_file(tchart, output_name);
 
pr_info("Written %2.1f seconds of trace to %s.\n",
-   (tchart->last_time - tchart->first_time) / 10.0, 
output_name);
+   (tchart->last_time - tchart->first_time) / 
(double)NSEC_PER_SEC, output_name);
 out_delete:
perf_session__delete(session);
return ret;
@@ -1901,10 +1902,10 @@ parse_time(const struct option *opt, const char *arg, 
int __maybe_unused unset)
if (sscanf(arg, "%" PRIu64 "%cs", value, ) > 0) {
switch (unit) {
case 'm':
-   *value *= 100;
+   *value *= NSEC_PER_MSEC;
break;
case 'u':
-   *value *= 1000;
+   *value *= NSEC_PER_USEC;
break;
case 'n':
break;
@@ -1928,7 +1929,7 @@ int cmd_timechart(int argc, const char **argv,
.ordered_events  = true,
},
.proc_num = 15,
-   .min_time = 100,
+   .min_time = NSEC_PER_MSEC,
.merge_dist = 1000,
};
const char *output_name = "output.svg";
diff --git a/tools/perf/util/svghelper.c b/tools/perf/util/svghelper.c
index eec6c11..1cbada2 100644
--- a/tools/perf/util/svghelper.c
+++ b/tools/perf/util/svghelper.c
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "perf.h"
 #include "svghelper.h"
@@ -274,14 +275,14 @@ static char *time_to_string(u64 duration)
 
text[0] = 0;
 
-   if (duration < 1000) /* less than 1 usec */
+   if (duration < NSEC_PER_USEC) /* less than 1 usec */
return text;
 
-   if (duration < 1000 * 1000) { /* less than 1 msec */
-   sprintf(text, "%.1f us", duration / 1000.0);
+   if (duration < NSEC_PER_MSEC) { /* less than 1 msec */
+   sprintf(text, "%.1f us", duration / (double)NSEC_PER_USEC);
return text;
}
-   sprintf(text, "%.1f ms", duration / 1000.0 / 1000);
+   sprintf(text, "%.1f ms", duration / (double)NSEC_PER_MSEC);
 
return text;
 }
@@ -297,7 +298,7 @@ void svg_waiting(int Yslot, int cpu, u64 start, u64 end, 
const char *backtrace)
 
style = "waiting";
 
-   if (end-start > 10 * 100) /* 10 msec */
+   if (end-start > 10 * NSEC_PER_MSEC) /* 10 msec */
style = "WAITING";
 
text = time_to_string(end-start);


[tip:perf/core] perf timechart: Use NSEC_PER_U?SEC

2016-08-24 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  af4b2c972a5fc9358486d946d15f32510534ccbf
Gitweb: http://git.kernel.org/tip/af4b2c972a5fc9358486d946d15f32510534ccbf
Author: Arnaldo Carvalho de Melo 
AuthorDate: Mon, 8 Aug 2016 12:45:58 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 23 Aug 2016 15:37:33 -0300

perf timechart: Use NSEC_PER_U?SEC

Following kernel practices, using linux/time64.h

Cc: Adrian Hunter 
Cc: Arjan van de Ven 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Stanislav Fomichev 
Cc: Steven Rostedt 
Cc: Wang Nan 
Link: http://lkml.kernel.org/n/tip-5l1md8lsdhfnrlsqyejzo...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-timechart.c | 13 +++--
 tools/perf/util/svghelper.c| 11 ++-
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c
index 733a554..e7eaa29 100644
--- a/tools/perf/builtin-timechart.c
+++ b/tools/perf/builtin-timechart.c
@@ -24,6 +24,7 @@
 #include "util/evlist.h"
 #include "util/evsel.h"
 #include 
+#include 
 #include "util/symbol.h"
 #include "util/callchain.h"
 #include "util/strlist.h"
@@ -1288,9 +1289,9 @@ static void draw_process_bars(struct timechart *tchart)
if (c->comm) {
char comm[256];
if (c->total_time > 50) /* 5 seconds */
-   sprintf(comm, "%s:%i (%2.2fs)", 
c->comm, p->pid, c->total_time / 10.0);
+   sprintf(comm, "%s:%i (%2.2fs)", 
c->comm, p->pid, c->total_time / (double)NSEC_PER_SEC);
else
-   sprintf(comm, "%s:%i (%3.1fms)", 
c->comm, p->pid, c->total_time / 100.0);
+   sprintf(comm, "%s:%i (%3.1fms)", 
c->comm, p->pid, c->total_time / (double)NSEC_PER_MSEC);
 
svg_text(Y, c->start_time, comm);
}
@@ -1637,7 +1638,7 @@ static int __cmd_timechart(struct timechart *tchart, 
const char *output_name)
write_svg_file(tchart, output_name);
 
pr_info("Written %2.1f seconds of trace to %s.\n",
-   (tchart->last_time - tchart->first_time) / 10.0, 
output_name);
+   (tchart->last_time - tchart->first_time) / 
(double)NSEC_PER_SEC, output_name);
 out_delete:
perf_session__delete(session);
return ret;
@@ -1901,10 +1902,10 @@ parse_time(const struct option *opt, const char *arg, 
int __maybe_unused unset)
if (sscanf(arg, "%" PRIu64 "%cs", value, ) > 0) {
switch (unit) {
case 'm':
-   *value *= 100;
+   *value *= NSEC_PER_MSEC;
break;
case 'u':
-   *value *= 1000;
+   *value *= NSEC_PER_USEC;
break;
case 'n':
break;
@@ -1928,7 +1929,7 @@ int cmd_timechart(int argc, const char **argv,
.ordered_events  = true,
},
.proc_num = 15,
-   .min_time = 100,
+   .min_time = NSEC_PER_MSEC,
.merge_dist = 1000,
};
const char *output_name = "output.svg";
diff --git a/tools/perf/util/svghelper.c b/tools/perf/util/svghelper.c
index eec6c11..1cbada2 100644
--- a/tools/perf/util/svghelper.c
+++ b/tools/perf/util/svghelper.c
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "perf.h"
 #include "svghelper.h"
@@ -274,14 +275,14 @@ static char *time_to_string(u64 duration)
 
text[0] = 0;
 
-   if (duration < 1000) /* less than 1 usec */
+   if (duration < NSEC_PER_USEC) /* less than 1 usec */
return text;
 
-   if (duration < 1000 * 1000) { /* less than 1 msec */
-   sprintf(text, "%.1f us", duration / 1000.0);
+   if (duration < NSEC_PER_MSEC) { /* less than 1 msec */
+   sprintf(text, "%.1f us", duration / (double)NSEC_PER_USEC);
return text;
}
-   sprintf(text, "%.1f ms", duration / 1000.0 / 1000);
+   sprintf(text, "%.1f ms", duration / (double)NSEC_PER_MSEC);
 
return text;
 }
@@ -297,7 +298,7 @@ void svg_waiting(int Yslot, int cpu, u64 start, u64 end, 
const char *backtrace)
 
style = "waiting";
 
-   if (end-start > 10 * 100) /* 10 msec */
+   if (end-start > 10 * NSEC_PER_MSEC) /* 10 msec */
style = "WAITING";
 
text = time_to_string(end-start);