C语言 获取系统时间与睡眠时间函数
2024-08-27 14:21:27
摘要:
以ms为单位,获取系统时间、睡眠或延迟时间函数的使用方法。
#include<stdio.h> #include <time.h> #include <sys/time.h> #include <unistd.h> typedef unsigned int uint32_t; #define csp_sleep_ms(time_ms) usleep(time_ms * 1000); uint32_t csp_get_ms() { struct timespec ts; ) { +ts.tv_nsec/); } else { ; } } int main() { uint32_t start = csp_get_ms(); csp_sleep_ms(); uint32_t time = csp_get_ms()-start; printf(" Reply in %u ms\r\n", time); ; }
重要函数说明:
参加百度百科:https://baike.baidu.com/item/clock_gettime
%u:表示无符号十进制整数。
最新文章
- 虚拟机VMware12.05下安装Ubuntu16.04几个关键地方
- WCF传输1-你是否使用过压缩或Json序列化?
- Spark MLib 基本统计汇总 2
- 深入剖析Java中的装箱和拆箱
- 读《C# 和 Java 的比较》有感
- C++ Primer 有感(异常处理)
- Vue 项目实战系列 (二)
- 简单购物车程序(Python)
- debian8下acme nginx 部署记录
- CSS实现水平垂直居中的1010种方式
- vuejs2.0与1.x版本中怎样使用js实时访问input的值的变化
- Js 常用字符串操作 API
- @ResponseBody注解
- springboot nginx 配置
- 第一章02: 常用的DOS命令
- 【洛谷P1638】逛画展
- 【转】asp.net项目在IE11下出现“__doPostBack”未定义的解决办法
- OpenHaptics编程环境搭建
- Django基于正则表达式的URL(2)
- elastic search internal
热门文章
- 精通CSS:高级WEB解决方案
- mysql:创建新库,新表,查看character
- The second day of Crawler learning
- 急速搭建 Serverless AI 应用:为你写诗
- Python 多态与抽象类
- $HDU$ 4352 ${XHXJ}&#39;s LIS$ 数位$dp$
- 为什么TCP建立连接协议是三次握手,而关闭连接却是四次握手呢?
- VMware 完成 27 亿美元的 Pivotal 收购 | 云原生生态周报 Vol. 34
- 【原创】快速失败机制&;失败安全机制
- graphviz 的使用教程