当前位置: 首页 > news >正文

Linux获取纳秒级别时间

  1. 在 Linux 系统中可以使用 gettimeofday 函数来获取时间,这个函数能够以毫秒的精度来获取时间
struct timeval tv;gettimeofday(&tv, NULL);time_t cur_time = tv.tv_sec;long cur_time_ms = tv.tv_usec/1000;printf(“cur_time = %d \n”, cur_time);printf(“cur_time_ms = %ld \n”, cur_time_ms);
  1. Linux 系统可以使用 clock_gettime 函数来获取时间精度,其可以以纳秒的精度获取时间
struct timespec ts;clock_gettime(CLOCK_REALTIME, &ts);Time_t cur_time = ts.tv_sec;long cur_time_us = ts.tv_nsec/1000;printf(“cur_time = %d \n”, cur_time);printf(“cur_time_us = %ld \n”, cur_time_us);
http://www.lryc.cn/news/150470.html

相关文章:

  • CSS中你不得不知道的盒子模型
  • 知识储备--基础算法篇-数组
  • zookeeper 理论合集
  • 【pyinstaller 怎么打包python,打包后程序闪退 不打日志 找不到自建模块等问题的踩坑解决】
  • 【Docker】网络
  • Linux :realpath 命令
  • react17:生命周期函数
  • 腾讯内部单边拥塞算法BBR-TCPA一键脚本安装
  • 【LLM】chatglm-6B模型训练和推理
  • 性能可靠it监控系统,性能监控软件的获得来源有哪些
  • TCP/IP网络编程(一) 理解网络编程和套接字
  • Python 潮流周刊#18:Flask、Streamlit、Polars 的学习教程
  • 装备一台ubuntu
  • 为了更好和大家交流,欢迎大家加我的微信账户
  • MS1826A HDMI 多功能视频处理器 HDMI4进1出画面分割芯片
  • 最新文献怎么找|学术最新前沿文献哪里找
  • ctfshow 红包题
  • SpringBoot项目(jar)部署,启动脚本
  • 大数据(四)主流大数据技术
  • 【已解决】激活虚拟环境报错:此时不应有Anaconda3\envs\[envs]\Library\ssl\cacert.pem。
  • Vue安装过程的困惑解答——nodejs和vue关系、webpack、vue-cli、vue的项目结构
  • PWA ~
  • YII项目在Docker中运行缓慢
  • 合宙Air724UG LuatOS-Air LVGL API控件--图表 (Chart)
  • Three.js之模型对象、材质
  • uniapp启动微信小程序开发者工具报错Enable IDE Service (y/N) 
  • Gitee注册和使用
  • 【Flutter】下载安装Flutter并使用学习dart语言
  • HTTP返回状态值详解整理
  • python web 开发与 Node.js + Express 创建web服务器入门