惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

GbyAI
GbyAI
J
Java Code Geeks
雷峰网
雷峰网
WordPress大学
WordPress大学
宝玉的分享
宝玉的分享
云风的 BLOG
云风的 BLOG
V
Visual Studio Blog
V
Vulnerabilities – Threatpost
S
Securelist
The Hacker News
The Hacker News
The Register - Security
The Register - Security
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Help Net Security
Help Net Security
G
Google Developers Blog
Hugging Face - Blog
Hugging Face - Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
M
MIT News - Artificial intelligence
AI
AI
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
The GitHub Blog
The GitHub Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Schneier on Security
Schneier on Security
N
Netflix TechBlog - Medium
T
The Blog of Author Tim Ferriss
Google DeepMind News
Google DeepMind News
Hacker News - Newest:
Hacker News - Newest: "LLM"
H
Hacker News: Front Page
博客园 - 司徒正美
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
B
Blog
Microsoft Azure Blog
Microsoft Azure Blog
大猫的无限游戏
大猫的无限游戏
Security Latest
Security Latest
Engineering at Meta
Engineering at Meta
N
News and Events Feed by Topic
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
酷 壳 – CoolShell
酷 壳 – CoolShell
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
T
Threat Research - Cisco Blogs
U
Unit 42
V
V2EX
V2EX - 技术
V2EX - 技术
L
LINUX DO - 最新话题
aimingoo的专栏
aimingoo的专栏
Microsoft Security Blog
Microsoft Security Blog
Recorded Future
Recorded Future
P
Privacy & Cybersecurity Law Blog
美团技术团队
小众软件
小众软件
F
Fortinet All Blogs

博客园 - Brendan

[转载]Manually configuring Microsoft Internet Information Services (IIS) IIS与TOMCAT协同工作---在IIS下运行JSP页面 AXIS部署错误解决方案集锦 使用System.Web.Mail发送Mail的错误解决方案 类的XML序列化(XML Serialization) [翻译]你可以赚钱,但你不能赚时间 Windows 2003 Server配置IIS服务器(ASP, ASP.NET)全功略 Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive 用MS SQL Server事件探查器来跟踪数据库的操作 反反编译工具——Deploy.NET Buffered I/O 与 Non-Buffered I/O性能差异的实例体验 替换函数(Substitution Function) 主定理(Master Theorem) Dynamic Programming之Longest Increasing Subsequence (LIS)问题 ADO.NET数据库连接模块 ASP.NET控件事件丢失的探究 SQLDMO For C#(翻译) 关联(Association)设计中的扇形陷阱(Fan Traps)和断层陷阱(Chasm Traps) 简单并发控制
C中获取当前时间的函数
Brendan · 2006-04-14 · via 博客园 - Brendan

        突然要用到C程序里调用当前时间,来测试一段代码的运行时间。找了一下是否有可以调用的库函数,没想到真的有:gettimeofday。因为这里的这个应用蛮常用的,所以留个记录在此。

 1 #include <stdio.h>
 2 #include <stdlib.h>
 3 
 4 struct timeval 
 5 
 6     long tv_sec; /* 秒数 */ 
 7     long tv_usec; /* 微秒数 */ 
 8 }; 
 9 
10 struct timezone 
11 
12     int tv_minuteswest; 
13     int tv_dsttime; 
14 }; 
15 
16 int gettimeofday(struct timeval *tv,struct timezone *tz); 
17 
18 void function()
19 {
20    // function to run some time consuming codes
21 }
22 
23 int main(int argc, char *argv[])
24 {
25     struct timeval tpstart,tpend;
26         float timespend; 
27 
28     gettimeofday(&tpstart,NULL); 
29     function();
30     gettimeofday(&tpend,NULL); 
31         timespend = tpend.tv_sec - tpstart.tv_sec;
32         printf("Time Spend: %d", timespend);
33     return EXIT_SUCCESS;
34 }