博客地址:http://home.cnblogs.com/u/zengjianrong/
摘要: https://mp.weixin.qq.com/s?__biz=MzAwMDUwNDgxOA==&mid=2652663676&idx=1&sn=b18ab57322594ebb8e7072e635e8bd1c&chksm=810f29e1b678a0f7238e8a71fd88f14c3c71e 阅读全文
posted @ 2019-08-01 02:02 black_man 阅读(903) 评论(0) 推荐(0) 编辑
摘要: AttributeError: module ‘collections‘ has no attribute ‘Mapping‘ 将collections替换为collections.abc即可 比如 from collections import Mapping # 替换为 from collect 阅读全文
posted @ 2024-03-07 20:31 black_man 阅读(8) 评论(0) 推荐(0) 编辑
摘要: 最小用例:https://github.com/google/benchmark?tab=readme-ov-file#usage 排除干扰:https://github.com/google/benchmark/blob/main/docs/reducing_variance.md 1. benm 阅读全文
posted @ 2024-03-05 15:37 black_man 阅读(13) 评论(0) 推荐(0) 编辑
摘要: 1. 优雅地实现单例模板,见::cereal::detail::StaticObject; 对比apollo的单例:https://zhuanlan.zhihu.com/p/391151328 2. 静态初始化,见CEREAL_CLASS_VERSION; 3. 静态类对象避免重定义,见::cere 阅读全文
posted @ 2023-06-08 10:52 black_man 阅读(56) 评论(0) 推荐(0) 编辑
摘要: 查看安装包版本信息:python3 -m pip freeze 安装:python3 -m pip install xxx 卸载:python3 -m pip uninstall xxx 更新:python3 -m pip install --upgrade pip setuptools wheel 阅读全文
posted @ 2023-05-31 16:14 black_man 阅读(9) 评论(0) 推荐(0) 编辑
摘要: 为了解决优先级反转,通常会给锁配置相关属性。 但,当锁的相关线程们,均配置的是CFS+同个nice时,由于vruntime大小差异导致的优先级反转,是否还能通过锁的配置属性生效? PTHREAD_PRIO_PROTECT + pthread_mutex_setprioceiling 此时应该只能通过 阅读全文
posted @ 2023-05-12 11:43 black_man 阅读(9) 评论(0) 推荐(0) 编辑
摘要: enable_shared_from_this:让类成员函数可获得自身的shared ptr封装,通过shared_from_this/weak_from_this API; 注意:调用shared_from_this的前提是此对象本身就是shared_ptr封装的类型,可通过将构造函数设置为私有、 阅读全文
posted @ 2023-04-04 18:53 black_man 阅读(20) 评论(0) 推荐(0) 编辑
摘要: https://godbolt.org/ 可在线编译执行,选择不同体系架构、不同版本的编译器; 可用于简单的验证编译器问题,比如优化选项带来的变化等。 编译加速:cmake UNITY_BUILD https://zhuanlan.zhihu.com/p/146434531 阅读全文
posted @ 2023-03-29 17:47 black_man 阅读(16) 评论(0) 推荐(0) 编辑
摘要: CMake梳理依赖关系 梳理依赖关系的方法,通常是在cmake命令中追加参数graphviz,如cmake .. --graphviz=../target_deps_graphviz,用来生成每个目标的依赖dot文件,再结合dot命令,如dot -Tpng -o target.png ./targe 阅读全文
posted @ 2022-12-28 16:27 black_man 阅读(52) 评论(0) 推荐(0) 编辑
摘要: strip两种方式: 1. 编译完成后手动strip; 2. 通过编译flags:"-s"直接strip; 方式一循环strip脚本: #!/bin/bash STRIP_CMD="strip" function read_dir(){ for file in `ls $1` do local pa 阅读全文
posted @ 2022-11-08 14:06 black_man 阅读(53) 评论(0) 推荐(0) 编辑
摘要: 有时我们需要将某些代码链接到指定的代码段,此时有两种方式: 1. 使用attribute属性指定 __attribute__((section("<name>"))); 2. 使用pragma section指定 #pragma section"<name>"[<flags>] [<alignmen 阅读全文
posted @ 2022-11-01 17:04 black_man 阅读(79) 评论(0) 推荐(0) 编辑