Linux C 获取系统时间秒/毫秒/微秒/纳秒
#include <stdio.h>
#include <string.h>
#include <sys/time.h> // gettimeofday
#include <sys/timeb.h> // ftime
#include <time.h> // time clock_gettime
#include <unistd.h>long get_system_time_nanosecond(); // 纳秒
long get_system_time_microsecond(); // 微秒
long get_system_time_millisecond(); // 毫秒
long get_system_time_second(); // 秒long get_system_time_nanosecond()
{struct timespec timestamp = {};if (0 == clock_gettime(CLOCK_REALTIME, ×tamp))return timestamp.tv_sec * 1000000000 + timestamp.tv_nsec;elsereturn 0;
}long get_system_time_microsecond()
{struct timeval timestamp = {};if (0 == gettimeofday(×tamp, NULL))return timestamp.tv_sec * 1000000 + timestamp.tv_usec;elsereturn 0;
}long get_system_time_millisecond()
{struct timeb timestamp = {};if (0 == ftime(×tamp))return timestamp.time * 1000 + timestamp.millitm;elsereturn 0;
}long get_system_time_second()
{return time(NULL);
}int main(int argc, char const *argv[])
{long second = get_system_time_second();long millisecond = get_system_time_millisecond();long microsecond = get_system_time_microsecond();long nanosecond = get_system_time_nanosecond();printf("%ld\n", second);printf("%ld\n", millisecond);printf("%ld\n", microsecond);printf("%ld\n", nanosecond);return 0;
}
Linux C 获取系统时间秒/毫秒/微秒/纳秒相关推荐
- 秒 毫秒 微秒 纳秒 皮秒 飞秒
millisecond 1ms (毫秒) 1毫秒=0.001秒=10-3秒 microsecond 1μs (微秒) 1微秒= ...
- 秒 毫秒 微秒 纳秒 皮秒。。时间单位换算
1s=1000ms=1000000微秒=1000000000纳秒=1000000000000皮秒=10^15飞秒=10^18啊秒=10^21仄秒=10^24幺秒 1s=10^3ms(毫秒)=10^6μ ...
- 计算耗时为微秒的方法(包含:时/分/秒/毫秒/微秒/纳秒)
计算耗时为微秒的方法1 #include<stdio.h> #include <windows.h> int main() {int a[10002];int i = 0;do ...
- 秒 毫秒 微秒 纳秒 Hz KHz MHz GHz
1S = 1000 毫秒 m 1S = 1000000 微秒 u 1S = 1000000000 纳秒 n 1S = 1000000000000 皮秒 p ... 1Hz 电磁脉冲 每秒钟周期震动 1 ...
- 秒 毫秒 微秒 纳秒 皮秒
0.000 001 微秒 = 1皮秒 0.001 微秒 = 1纳秒 微秒 1,000 微秒 = 1毫秒 1,000,000 微秒 = 1秒 1s = 1000ms 1ms = 1000μs 1μs = ...
- 秒,毫秒,微秒,纳秒,皮秒,飞秒
转载于:https://www.cnblogs.com/zb-ml/p/8988940.html
- linux获得系统时间 c,linux c 获取系统时间
#include main() { time_t timep; time (&timep); printf("%s",asctime(gmtime(&timep)) ...
- linux获得系统时间 c,linux c 获取系统时间的方法
比如获取当前年份: /* 获取当前系统时间 暂时不使用 int iyear = 0; int sysyear = 0; time_t now; struct tm *timenow; time(&am ...
- linux下获取系统时间的方法
可以用 localtime 函数分别获取年月日时分秒的数值. Linux下获得系统时间的C语言的实现方法: 1. 可以用 localtime 函数分别获取年月日时分秒的数值. #include< ...
最新文章
- 精简易懂,30 分钟学会 SVD 矩阵分解,很强!
- 《微服务:从设计到部署》中文版
- FreeSql (十九)多表查询
- 【软件测试】测试需求分析
- mysql中表的约束,主键外键唯一键
- PRML笔记 第一章 Introduction
- abaqus python二次开发攻略_Abaqus二次开发Python脚本二次开发
- 从软件工程的角度比较Swift、Go和Julia,我有了这些发现
- lua脚本之lua语言简介以及lua的安装
- 华三 h3c STP生成树保护配置
- 工行u盾显示316_工行银行网上交易老是提示插入u盾
- 微信公众平台:微信网页授权和微信支付
- 【Web】HTML基础——了解HMTL基本结构+常用标签的使用
- 网络附加存储(NAS)
- Jmeter读取CSV文件读取不到解决方法
- 纯css3卡通火龙果
- 一些学习经验总结和分享
- RabbitMQ的Qos
- 【ECCV2020】Spatio-Temporal Graph Transformer Networks for Pedestrian Trajectory Prediction
- MongoDB——聚合操作