linux内核中添加时间函数

本文探讨了Linux内核中页面拷贝操作的优化方法。通过比较两种不同的时间记录方式,展示了如何减少不必要的开销并提高效率。
//添加的头文件
# include <linux/cache.h>
# include <linux/seqlock.h>
# include <linux/math64.h>
# include <linux/time64.h>
# include <linux/time.h>



//具体方法:
printk("-*- before read page,timestamp:%lu\n",gettime());
ret = copy_page_to_iter(page, offset, nr, iter);
printk("-*- before read page,timestamp:%lu\n",gettime());
		
//【注意】:该方法包含了printk的时间



//改进方法:
unsigned long time1,time2;      /* offset into pagecache page */
		
time1=gettime();
ret = copy_page_to_iter(page, offset, nr, iter);
time2=gettime()

printk("-*-time:%lu\n",time2-time1);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值