![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++性能优化指南
楼兰公子
这个作者很懒,什么都没留下…
展开
-
[内核]调度算法
头文件kernel_schedule_mlfq.cpp定义#ifndef KERNEL_SCHEDULE_MLFQ_H#define KERNEL_SCHEDULE_MLFQ_H#include<iostream>#include<queue>#include<list>#include<unistd.h>#include<linux/types.h>using namespace std;struct pro{原创 2021-08-08 18:43:05 · 127 阅读 · 0 评论 -
linux 获取本地IP地址信息C++版本
#include <stdio.h>#include <string.h>#include <net/if.h>#include <sys/ioctl.h>#include <arpa/inet.h>#include <errno.h>#include<stdlib.h>#include<unistd.h>int getLocalInfo(void){ int fd; int .原创 2020-10-30 11:45:43 · 758 阅读 · 0 评论 -
core dump 调试开关打开之C代码
/* ============================================================================ Name : switch_core.c Author : Version : Copyright : Your copyright notice Description : Hello World in C, Ansi-style ================================.原创 2020-07-28 19:50:03 · 1115 阅读 · 0 评论 -
PIMPL的使用理由
private Implementation 1.降低模块耦合度 2.降低编译依赖,提高编译速度 3.接口与实现分离,提高接口稳定性 原理:在公共接口里封装私有数据和方法,将类的实现细节放在分离的指针访问类中。 用途:这种方法用于构造稳定的ABI的C++库接口,减少编译依赖 现代C++不鼓励 owning raw pointers ,可以使用智能指针实现PIMPL...原创 2020-07-08 15:51:05 · 181 阅读 · 0 评论 -
C++的PIMPL实现
private Implementation 1.降低模块耦合度 2.降低编译依赖,提高编译速度 3.接口与实现分离,提高接口稳定性 原理:在公共接口里封装私有数据和方法,将类的实现细节放在分离的指针访问类中。 用途:这种方法用于构造稳定的ABI的C++库接口,减少编译依赖 现代C++不鼓励使用原始指针 ,可以使用智能指针实现PIMPL示例代码#include <iostream>#include <memory>class Ap.原创 2020-06-15 14:01:35 · 237 阅读 · 0 评论 -
jsoncpp添加各种类型成员
Json::Value root; root["jsonrpc"]="2.0"; root["id"]=98; root["method"]="call"; root["params"].append("00000000000000000000000000000000000000"); root["params"].append("kpalive"); root["params"].append("status"); root["params...原创 2020-06-11 14:56:27 · 362 阅读 · 0 评论 -
统计文件行数
int count_lines(const std::string &filename){ std::ifstream in(filename); return std::count(std::istreambuf_iterator<char>(in),std::istreambuf_iterator<char>(),'\n');}原创 2020-05-23 17:43:09 · 173 阅读 · 0 评论 -
移植交叉编译库文件出现找不到头文件现象error : while loading shared libraries: libxxxx.so cannot open shared object file
分析原因:链接器ld提示找不到库文件。ld默认的目录是/lib和/usr/lib,如果放在其他路径也可以,需要让ld知道库文件所在的路径。二、解决方法1:# vim /etc/ld.so.conf //在新的一行中加入库文件所在目录/home/xxx/3rdlib# ldconfig //更新/etc/ld.so.cache文件方法2:1.将用户用到的库统一放到一个目录,如 /usr/loca/lib# cp libXXX.so.X...原创 2020-05-14 19:23:48 · 637 阅读 · 0 评论 -
Linux库文件拷贝后刷新操作
sudo ldconfig原创 2020-05-09 20:54:11 · 372 阅读 · 0 评论 -
三元运算符存在的隐式转换现象
#include<stdio.h>int main(){ int x = 4; printf("%d\n",x>4?99.0:9); printf("%d\n",x>4?99:9); printf("%d\n",x>4?99:9.0); printf("%f\n",x>4?99:9.0); if(x>4){ printf("%d\n",99.0); }else{ printf("%f\n",9); .原创 2020-05-09 10:08:05 · 605 阅读 · 0 评论 -
hyper_graph.h:41:10: fatal error: 'tr1/unordered_map' file not found
#if(__cplusplus == 201103L)#include <unordered_map>#include <unordered_set>#else#include <tr1/unordered_map>#include <tr1/unordered_set>namespace std{ using std::tr1...原创 2020-05-03 17:54:38 · 1110 阅读 · 0 评论 -
cppcheck的基本使用
cppcheck能够自行递归遍历子目录中的文件夹所以只需要 cppcheck src即可 cppcheck 保存错误信息 cppcheck 2>result.txt即可 cppcheck 检查所有项目可采用 cppcheck --enable=all...原创 2020-04-30 15:00:25 · 584 阅读 · 0 评论 -
errno字符打印
/* Function: obtain the errno string* char *strerror(int errno)*/#include <stdio.h>#include <string.h> //for strerror()//#include <errno.h>int main(){ int errID= 0...原创 2020-04-30 14:51:59 · 341 阅读 · 0 评论 -
亚微秒级别的时间测量
Windows:GetSystemTimePreciseAsfileTimeLinux: clock_gettime https://ubuntuqa.com/article/9295.html https://www.91r.net/ask/7935545.html...原创 2020-04-24 01:03:24 · 864 阅读 · 0 评论