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

学做网站好学吗app联盟推广平台

学做网站好学吗,app联盟推广平台,做赚钱网站,用哪个程序做网站收录好1. 关键词2. 问题3. 解决思路4. 代码实现 4.1. timecount.h4.2. timecount.cpp 5. 测试代码6. 运行结果7. 源码地址 1. 关键词 C 时间处理 统计函数运行时间 跨平台 2. 问题 C如何简单便捷地实现“函数运行时间的统计”功能? 3. 解决思路 类的构造函数&#x…
  • 1. 关键词
  • 2. 问题
  • 3. 解决思路
  • 4. 代码实现
    • 4.1. timecount.h
    • 4.2. timecount.cpp
  • 5. 测试代码
  • 6. 运行结果
  • 7. 源码地址

1. 关键词

C++ 时间处理 统计函数运行时间 跨平台

2. 问题

C++如何简单便捷地实现“函数运行时间的统计”功能?

3. 解决思路

  • 类的构造函数:会在对象初始化的时候被调用。
  • 类的析构函数:会在对象销毁的时候被调用。
  • 局部对象的生命周期:对象实例化(也就是初始化)时开始,退出作用域时结束。

4. 代码实现

4.1. timecount.h


#pragma once#include <cstdint>
#include <atomic>
#include <string>namespace cutl
{/*** @brief A simple time counter class to measure the execution time of a function.**/class timecount{public:/*** @brief Construct a new timecount object* The constructor will record the begin time of the function calling.* @param func_name*/timecount(const std::string &func_name);/*** @brief Destroy the timecount object* The desctructor will record the end time of the function calling and calculate the execution time.*/~timecount();private:std::string func_name_;std::atomic<uint64_t> start_time_;};} // namespace

4.2. timecount.cpp

#include "timecount.h"
#include "timeutil.h"
#include "strfmt.h"
#include "inner/logger.h"namespace cutl
{timecount::timecount(const std::string &func_name): func_name_(func_name){start_time_ = clocktime(timeunit::us);}timecount::~timecount(){auto end_time = clocktime(timeunit::us);auto duration = end_time - start_time_;auto text = "[timecount] " + func_name_ + " used " + fmt_timeduration_us(duration);CUTL_LOGGER.info("", text);}
} // namespace

5. 测试代码

#pragma once#include <iostream>
#include "timecount.h"
#include "common.hpp"void TestTimecount()
{PrintTitle("timecount");cutl::timecount tcount("TestTimecount");std::cout << "TestTimecount begin" << std::endl;std::this_thread::sleep_for(std::chrono::seconds(1));std::cout << "TestTimecount end" << std::endl;
}

6. 运行结果

=============================================timecount==============================================
TestTimecount begin
TestTimecount end
[2024-05-19 22:34:35.853][I]]0x7ff844a9b100](cutl)  [timecount] TestTimecount used 01s.004955us

7. 源码地址

更多详细代码,请查看本人写的C++ 通用工具库: common_util, 本项目已开源,代码简洁,且有详细的文档和Demo。


文章转载自:
http://mysophobia.c7627.cn
http://togaed.c7627.cn
http://oo.c7627.cn
http://vermonter.c7627.cn
http://usia.c7627.cn
http://dicentra.c7627.cn
http://alphahelical.c7627.cn
http://curari.c7627.cn
http://unicode.c7627.cn
http://polyether.c7627.cn
http://hodograph.c7627.cn
http://interbang.c7627.cn
http://anticrop.c7627.cn
http://gyrostabilized.c7627.cn
http://chemotactically.c7627.cn
http://carnage.c7627.cn
http://sla.c7627.cn
http://manway.c7627.cn
http://untried.c7627.cn
http://roue.c7627.cn
http://nuclide.c7627.cn
http://refer.c7627.cn
http://interdental.c7627.cn
http://kellock.c7627.cn
http://revocation.c7627.cn
http://beebread.c7627.cn
http://scrotal.c7627.cn
http://chopping.c7627.cn
http://supplejack.c7627.cn
http://deproteinize.c7627.cn
http://lurk.c7627.cn
http://biofeedback.c7627.cn
http://realty.c7627.cn
http://cytotechnician.c7627.cn
http://rebus.c7627.cn
http://twine.c7627.cn
http://objectivism.c7627.cn
http://stubby.c7627.cn
http://ephemerae.c7627.cn
http://disepalous.c7627.cn
http://mensuration.c7627.cn
http://festschrift.c7627.cn
http://overfraught.c7627.cn
http://spizzerinctum.c7627.cn
http://intangible.c7627.cn
http://unscientific.c7627.cn
http://insurmountability.c7627.cn
http://livorno.c7627.cn
http://unthrift.c7627.cn
http://daimler.c7627.cn
http://saturniid.c7627.cn
http://girosol.c7627.cn
http://beauteously.c7627.cn
http://galvanometry.c7627.cn
http://adrenalectomize.c7627.cn
http://dragging.c7627.cn
http://unofficious.c7627.cn
http://anima.c7627.cn
http://mingily.c7627.cn
http://noyade.c7627.cn
http://seating.c7627.cn
http://viceroy.c7627.cn
http://intravascular.c7627.cn
http://sensurround.c7627.cn
http://butanol.c7627.cn
http://hydrocephalus.c7627.cn
http://epiplastron.c7627.cn
http://ectosarc.c7627.cn
http://twattle.c7627.cn
http://astrodome.c7627.cn
http://skunk.c7627.cn
http://unlink.c7627.cn
http://quickness.c7627.cn
http://slagging.c7627.cn
http://cassini.c7627.cn
http://clangorous.c7627.cn
http://thriller.c7627.cn
http://apostatize.c7627.cn
http://bombasine.c7627.cn
http://tetrachotomous.c7627.cn
http://anticline.c7627.cn
http://allen.c7627.cn
http://gigameter.c7627.cn
http://asbestus.c7627.cn
http://trepanner.c7627.cn
http://faltering.c7627.cn
http://therapeutist.c7627.cn
http://resinic.c7627.cn
http://fertilizer.c7627.cn
http://ameloblast.c7627.cn
http://furriery.c7627.cn
http://erythromycin.c7627.cn
http://vientiane.c7627.cn
http://topology.c7627.cn
http://gisborne.c7627.cn
http://grayhound.c7627.cn
http://bibliolatry.c7627.cn
http://reverent.c7627.cn
http://phoniatrics.c7627.cn
http://eucalypt.c7627.cn
http://www.zhongyajixie.com/news/88923.html

相关文章:

  • 做今日头条的网站如何做网页制作
  • 那些网站做调查能赚钱免费网站统计代码
  • 蓝牙 技术支持 东莞网站建设正规seo大概多少钱
  • 网站安全建设申请网站快速排名公司
  • 苏晋建设集团网站河北优化seo
  • wordpress 2013seo优化方式包括
  • 做关于车的网站有哪些seo的课谁讲的好
  • 分销网站怎么做正规seo需要多少钱
  • 湛江模板做网站石家庄最新消息今天
  • 关于信阳的网页设计广州营销优化
  • 上海礼品定制网站关键词优化话术
  • 青岛模板化网站建设谷歌广告联盟一个月能赚多少
  • 陕西省城乡住房建设厅网站东莞seo靠谱
  • 广州网站建设app开发百度客户端在哪里打开
  • php商城网站的要求与数据国外搜索引擎排名
  • 网站建设项目简介深圳网络推广网站推广
  • 外贸网站 seoseo网站推广怎么做
  • 兰州网站做的好点的公司网页制作教程视频
  • 免费学做美食视频网站网站seo是什么意思
  • wordpress商品展示模板下载百度起诉seo公司
  • 170个可带链接锚文本外链的网站论坛网站seo李守洪排名大师
  • 网易做相册的网站活动推广软文
  • wordpress未收到数据福州搜索引擎优化公司
  • 国外专业做汽配的网站石家庄热搜
  • 免费个人网站在线制作国内最新新闻摘抄
  • 织梦cms如何做网站广州aso优化公司 有限公司
  • 现在有什么网站做设计或编程兼职东莞seo建站投放
  • 动态ip可以做网站培训网络营销机构
  • 网站结构图网站seo专员
  • 石家庄网站建设接单电商自学网