* [makedumpfile PATCHv3 1/2] fold the calc of time delta into a func
@ 2017-06-14 9:41 Pingfan Liu
0 siblings, 0 replies; 2+ messages in thread
From: Pingfan Liu @ 2017-06-14 9:41 UTC (permalink / raw)
To: kexec; +Cc: Pratyush Anand, Atsushi Kumagai
This piece of code will be used by more than one function after
introducing the next patch
Signed-off-by: Pingfan Liu <piliu@redhat.com>
---
print_info.c | 28 ++++++++++++++++------------
1 file changed, 16 insertions(+), 12 deletions(-)
diff --git a/print_info.c b/print_info.c
index 832196d..79dfe5e 100644
--- a/print_info.c
+++ b/print_info.c
@@ -337,6 +337,19 @@ print_usage(void)
MSG("\n");
}
+static void calc_delta(struct timeval *tv_start, struct timeval *delta)
+{
+ struct timeval tv_end;
+
+ gettimeofday(&tv_end, NULL);
+ delta->tv_sec = tv_end.tv_sec - tv_start->tv_sec;
+ delta->tv_usec = tv_end.tv_usec - tv_start->tv_usec;
+ if (delta->tv_usec < 0) {
+ delta->tv_sec--;
+ delta->tv_usec += 1000000;
+ }
+}
+
void
print_progress(const char *msg, unsigned long current, unsigned long end)
{
@@ -369,19 +382,10 @@ print_progress(const char *msg, unsigned long current, unsigned long end)
void
print_execution_time(char *step_name, struct timeval *tv_start)
{
- struct timeval tv_end;
- time_t diff_sec;
- suseconds_t diff_usec;
+ struct timeval delta;
- gettimeofday(&tv_end, NULL);
-
- diff_sec = tv_end.tv_sec - tv_start->tv_sec;
- diff_usec = tv_end.tv_usec - tv_start->tv_usec;
- if (diff_usec < 0) {
- diff_sec--;
- diff_usec += 1000000;
- }
+ calc_delta(tv_start, &delta);
REPORT_MSG("STEP [%s] : %ld.%06ld seconds\n",
- step_name, diff_sec, diff_usec);
+ step_name, delta.tv_sec, delta.tv_usec);
}
--
2.7.4
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply related [flat|nested] 2+ messages in thread* [makedumpfile PATCHv3 1/2] fold the calc of time delta into a func
@ 2017-06-14 9:41 Pingfan Liu
0 siblings, 0 replies; 2+ messages in thread
From: Pingfan Liu @ 2017-06-14 9:41 UTC (permalink / raw)
To: kexec; +Cc: Pratyush Anand, Atsushi Kumagai
This piece of code will be used by more than one function after
introducing the next patch
Signed-off-by: Pingfan Liu <piliu@redhat.com>
---
print_info.c | 28 ++++++++++++++++------------
1 file changed, 16 insertions(+), 12 deletions(-)
diff --git a/print_info.c b/print_info.c
index 832196d..79dfe5e 100644
--- a/print_info.c
+++ b/print_info.c
@@ -337,6 +337,19 @@ print_usage(void)
MSG("\n");
}
+static void calc_delta(struct timeval *tv_start, struct timeval *delta)
+{
+ struct timeval tv_end;
+
+ gettimeofday(&tv_end, NULL);
+ delta->tv_sec = tv_end.tv_sec - tv_start->tv_sec;
+ delta->tv_usec = tv_end.tv_usec - tv_start->tv_usec;
+ if (delta->tv_usec < 0) {
+ delta->tv_sec--;
+ delta->tv_usec += 1000000;
+ }
+}
+
void
print_progress(const char *msg, unsigned long current, unsigned long end)
{
@@ -369,19 +382,10 @@ print_progress(const char *msg, unsigned long current, unsigned long end)
void
print_execution_time(char *step_name, struct timeval *tv_start)
{
- struct timeval tv_end;
- time_t diff_sec;
- suseconds_t diff_usec;
+ struct timeval delta;
- gettimeofday(&tv_end, NULL);
-
- diff_sec = tv_end.tv_sec - tv_start->tv_sec;
- diff_usec = tv_end.tv_usec - tv_start->tv_usec;
- if (diff_usec < 0) {
- diff_sec--;
- diff_usec += 1000000;
- }
+ calc_delta(tv_start, &delta);
REPORT_MSG("STEP [%s] : %ld.%06ld seconds\n",
- step_name, diff_sec, diff_usec);
+ step_name, delta.tv_sec, delta.tv_usec);
}
--
2.7.4
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-06-14 9:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-14 9:41 [makedumpfile PATCHv3 1/2] fold the calc of time delta into a func Pingfan Liu
-- strict thread matches above, loose matches on Subject: below --
2017-06-14 9:41 Pingfan Liu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox