1 #include <ace/ACE.h>
2
3 #include <ace/OS.h>
4
5 #include <ace/Log_Msg.h>
6
7 using namespace std;
8
9 int main(int argc, char *argv[])
10
11 {
12
13 ACE_DEBUG(( LM_NOTICE, "%D\n" ));
14
15 ACE_OS::sleep( ACE_Time_Value(0,1*1000) );
16
17 ACE_DEBUG(( LM_NOTICE, "%D sleep 1\n" ));
18
19 ACE_OS::sleep( ACE_Time_Value(0,5*1000) );
20
21 ACE_DEBUG(( LM_NOTICE, "%D sleep 5\n" ));
22
23 ACE_OS::sleep( ACE_Time_Value(0,10*1000) );
24
25 ACE_DEBUG(( LM_NOTICE, "%D sleep 10\n" ));
26
27 ACE_OS::sleep( ACE_Time_Value(0,50*1000) );
28
29 ACE_DEBUG(( LM_NOTICE, "%D sleep 50\n" ));
30
31 ACE_OS::sleep( ACE_Time_Value(0,100*1000) );
32
33 ACE_DEBUG(( LM_NOTICE, "%D sleep 100\n" ));
34
35 ACE_OS::sleep( ACE_Time_Value(0,1000*1000) );
36
37 ACE_DEBUG(( LM_NOTICE, "%D sleep 1000\n" ));
38
39 return EXIT_SUCCESS;
40
41 }
42
linux下的结果:
Sat Jan 12 2008 20:55:26.459703
Sat Jan 12 2008 20:55:26.460899 sleep 1 // 1.196ms
Sat Jan 12 2008 20:55:26.466037 sleep 5 // 5.138ms
Sat Jan 12 2008 20:55:26.476203 sleep 10 // 10.166ms
Sat Jan 12 2008 20:55:26.526348 sleep 50 // 50.145ms
Sat Jan 12 2008 20:55:26.626466 sleep 100 // 100.118ms
Sat Jan 12 2008 20:55:27.626739 sleep 1000 // 1000.273ms
windows下的结果:
Sat Jan 12 2008 22:51:07.993000
Sat Jan 12 2008 22:51:08.009000 sleep 1 // 16ms
Sat Jan 12 2008 22:51:08.009000 sleep 5 // 0ms
Sat Jan 12 2008 22:51:08.024000 sleep 10 // 15ms
Sat Jan 12 2008 22:51:08.071000 sleep 50 // 27ms
Sat Jan 12 2008 22:51:08.181000 sleep 100 //110ms
Sat Jan 12 2008 22:51:09.181000 sleep 1000 // 1000ms
由此看来,windows下sleep的精度为15ms,,但是1000ms以下的误差都比较大
posted on 2009-07-29 10:51
老马驿站 阅读(3167)
评论(0) 编辑 收藏 引用 所属分类:
ACE