* [LTP] [PATCH v2] difftime/1-1: eliminate sleep
@ 2015-02-23 14:53 Jan Stancek
2015-02-23 15:07 ` Cyril Hrubis
0 siblings, 1 reply; 2+ messages in thread
From: Jan Stancek @ 2015-02-23 14:53 UTC (permalink / raw)
To: ltp-list
No need to sleep for 1 sec, we can compute second time
immediately and pass it to difftime.
Suggested-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
.../open_posix_testsuite/conformance/interfaces/difftime/1-1.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/difftime/1-1.c b/testcases/open_posix_testsuite/conformance/interfaces/difftime/1-1.c
index 97bf443..1d2e19f 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/difftime/1-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/difftime/1-1.c
@@ -15,18 +15,16 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+#include <sys/time.h>
#include "posixtest.h"
int main(void)
{
- time_t time1, time0;
-
+ time_t time0;
double time_diff;
- time_diff = 0;
+
time0 = time(NULL);
- sleep(WAIT_DURATION);
- time1 = time(NULL);
- time_diff = difftime(time1, time0);
+ time_diff = difftime(time0 + 1, time0);
if (time_diff != WAIT_DURATION) {
perror
--
1.8.3.1
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-02-23 15:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-23 14:53 [LTP] [PATCH v2] difftime/1-1: eliminate sleep Jan Stancek
2015-02-23 15:07 ` Cyril Hrubis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox