|
本帖最后由 lmn2005 于 2022-6-1 07:56 编辑
本人用
ticker.attach_ms(500, task);
来设置每500毫秒运行一次task任务。
每2次任务即1秒,时间参数Mysec加1;当Mysec为0时,自动获取网络时间并打印下来,结果如下:
Mysec:19Mysec:20Mysec:21Mysec:22Mysec:23Mysec:24Mysec:25Mysec:26Mysec:27Mysec:28Mysec:29Mysec:30Mysec:31Mysec:32Mysec:33Mysec:34Mysec:35Mysec:36Mysec:37Mysec:38Mysec:39Mysec:40Mysec:41Mysec:42Mysec:43Mysec:44Mysec:45Mysec:46Mysec:47Mysec:48Mysec:49Mysec:50Mysec:51Mysec:52Mysec:53Mysec:54Mysec:55Mysec:56Mysec:57Mysec:58Mysec:59[HTTP] GET... code: 200
{"sysTime2":"2022-05-27 15:42:22","sysTime1":"20220527154222"}
22
5
27
15
42
22
Mysec:22Mysec:23Mysec:24Mysec:25Mysec:26Mysec:27Mysec:28Mysec:29Mysec:30Mysec:31Mysec:32Mysec:33Mysec:34Mysec:35Mysec:36Mysec:37Mysec:38Mysec:39Mysec:40Mysec:41Mysec:42Mysec:43Mysec:44Mysec:45Mysec:46Mysec:47Mysec:48Mysec:49Mysec:50Mysec:51Mysec:52Mysec:53Mysec:54Mysec:55Mysec:56Mysec:57Mysec:58Mysec:59[HTTP] GET... code: 200
{"sysTime2":"2022-05-27 15:43:19","sysTime1":"20220527154319"}
22
5
27
15
从上面可以看出,当定时器为0时,网络时间的秒已经到了22,这说明内部的秒比起网络的时间差不多慢了21秒、22秒。
每分钟慢21、22秒,误差大得惊人,为什么会这样呢?
|
|