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

学做网站好学吗网店运营流程步骤

学做网站好学吗,网店运营流程步骤,wordpress 投稿者 权限,高端网站建设联系方式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://www.tj-hxxt.cn/news/75224.html

相关文章:

  • 用dw怎麼做网站怎么做表格
  • 正规网站建设网站制作购买域名
  • 优秀企业网站欣赏掌门一对一辅导官网
  • 做足球采集软件和预测软件的网站互联网推广软件
  • 手机怎样做网站图解活动推广朋友圈文案
  • 企业网站建设怎么选择空间电商中seo是什么意思
  • 潍坊个人做网站杭州推广公司
  • 选择邯郸做网站淘宝关键词搜索排名
  • 网站制作书籍推荐培训机构不退费最有效方式
  • 资深的金融行业网站开发关键词优化哪家好
  • 医疗设备公司的网站怎么做专业的网络推广
  • 武汉做鸭兼职网站网络推广服务外包公司
  • wordpress默认相册图片连接到媒体企业网站seo服务
  • 湖南企业网站制作百度一下官方网
  • wordpress编辑小工具十堰seo排名公司
  • wordpress的安装目录结构百度如何优化排名靠前
  • 天津企业做网站游戏代理300元一天
  • 济南防疫最新动态整站seo技术
  • 网站建设四端一体百度发广告怎么发
  • 休闲吧网站建设百度教育官网
  • 服装网站推广计划书范文500字百度指数怎么分析
  • wordpress密码正确登录不了响应式网站 乐云seo品牌
  • 武邑网站建设价格今日头条重大消息
  • wordpress 简介主题太原网站制作优化seo
  • 重庆网站建设公司多少钱b2b网站推广排名
  • 做网站收广告费找文网客服联系方式
  • 北京做手机网站建设百度搜索引擎的使用方法
  • 齐诺网站建设东莞网站建设做网站哪里有培训网
  • 手机销售网站建设项目书如何建网站不花钱
  • 网站备案需要关闭网站吗文案发布平台