1 2 3 |
E:\sourcecode\tmp\qt-everywhere-src-5.15.9\configure.bat -static -static-runtime -release -platform win32-msvc -prefix D:\Qt\Static5.15 -confirm-license -opensource -nomake examples -nomake tests -opengl desktop -no-icu -skip qtwebengine -mp |
QT智能指针与裸指针的性能对比测试
代码是gpt直接生成的,感觉没毛病
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
#include <QCoreApplication> #include <QDebug> #include <QSharedPointer> #include <chrono> class MyClass { public: MyClass(int value) : value_(value) {} int getValue() const { return value_; } private: int value_; }; void testSharedPointer() { auto startTime = std::chrono::high_resolution_clock::now(); for (int i = 0; i < 30000000; ++i) { QSharedPointer<MyClass> ptr(new MyClass(i)); // 多次参数传递 func1(ptr); } auto endTime = std::chrono::high_resolution_clock::now(); auto elapsedTime = std::chrono::duration_cast<std::chrono::milliseconds>(endTime - startTime).count(); qDebug() << "QSharedPointer elapsed time:" << elapsedTime << "ms"; } void func1(QSharedPointer<MyClass> ptr) { // 参数传递 func2(ptr); } void func2(QSharedPointer<MyClass> ptr) { // 参数传递 func3(ptr); } void func3(QSharedPointer<MyClass> ptr) { int value = ptr->getValue(); Q_UNUSED(value); } void testBarePointer() { auto startTime = std::chrono::high_resolution_clock::now(); for (int i = 0; i < 30000000; ++i) { MyClass* ptr = new MyClass(i); // 多次参数传递 func4(ptr); delete ptr; } auto endTime = std::chrono::high_resolution_clock::now(); auto elapsedTime = std::chrono::duration_cast<std::chrono::milliseconds>(endTime - startTime).count(); qDebug() << "Bare pointer elapsed time:" << elapsedTime << "ms"; } void func4(MyClass* ptr) { // 参数传递 func5(ptr); } void func5(MyClass* ptr) { // 参数传递 func6(ptr); } void func6(MyClass* ptr) { int value = ptr->getValue(); Q_UNUSED(value); } int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); testSharedPointer(); testBarePointer(); return a.exec(); } |
在上述示例代码中,我们定义了一个名为 MyClass 的类,它包含一个整型成员变量。然后,我们分别实现了两个函数:testSharedPointer 和 testBarePointer,用于测试 QSharedPointer 指针和裸指针……
Git 中出现 ^M 解决方案
windows server2022 使用记录
git ssh端口非22端口解决方案
gitea 无法ssh clone push解决
替换垃圾WIN11的任务栏,支持任务不合并
Linux实时监控网卡网速及流量
脚本查看实时速度
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
#!/bin/bash ethn=$1 while true do RX_pre=$(cat /proc/net/dev | grep $ethn | sed 's/:/ /g' | awk '{print $2}') TX_pre=$(cat /proc/net/dev | grep $ethn | sed 's/:/ /g' | awk '{print $10}') sleep 1 RX_next=$(cat /proc/net/dev | grep $ethn | sed 's/:/ /g' | awk '{print $2}') TX_next=$(cat /proc/net/dev | grep $ethn | sed 's/:/ /g' | awk '{print $10}') clear echo -e "\t RX `date +%k:%M:%S` TX" RX=$((${RX_next}-${RX_pre})) TX=$((${TX_next}-${TX_pre})) if [[ $RX -lt 1024 ]];then RX="${RX}B/s" elif [[ $RX -gt 1048576 ]];then RX=$(echo $RX | awk '{print $1/1048576 "MB/s"}') else RX=$(echo $RX | awk '{print $1/1024 "KB/s"}') fi if [[ $TX -lt 1024 ]];then TX="${TX}B/s" elif [[ $TX -gt 1048576 ]];then TX=$(echo $TX | awk '{print $1/1048576 "MB/s"}') else TX=$(echo $TX | awk '{print $1/1024 "KB/s"}') fi echo -e "$ethn \t $RX $TX " done |
使用 watch watch -n 1 “ifconfig eth0” watch -n 1 “cat /proc/net/dev”
密码保护:FFMPEG log
i2cdetect 工具简单使用
列出所有I2C设备 i2cdetect -l 返回
1 2 3 4 5 |
i2c-3 i2c xiic-i2c I2C adapter i2c-1 i2c Cadence I2C at ff020000 I2C adapter i2c-2 i2c Cadence I2C at ff030000 I2C adapter i2c-0 i2c xiic-i2c I2C adapter |
列出总线上所有有回应的设备
1 2 3 4 5 6 7 8 9 10 11 |
i2cdetect -y -r 1 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- 18 -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- -- 50: -- UU -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- -- |
读取某个设备上的 00~FF的内容
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
i2cdump -f -y 3 0x18 No size specified (using byte-data access) 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef 00: 00 00 00 10 04 00 00 00 00 00 00 01 00 00 00 80 ...??......?...? 10: 80 ff ff 78 78 78 78 78 78 06 00 fe 00 00 fe 00 ?..xxxxxx?.?..?. 20: 00 00 00 00 10 00 00 00 00 00 00 80 80 00 00 00 ....?......??... 30: 00 00 00 04 00 00 00 00 00 00 04 00 00 00 00 00 ...?......?..... 40: 00 04 00 00 00 00 00 00 04 00 00 00 00 00 00 00 .?......?....... 50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 60: 00 00 00 00 00 00 02 00 00 00 00 00 00 00 00 00 ......?......... 70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 80: 00 00 00 10 04 00 00 00 00 00 00 01 00 00 00 80 ...??......?...? 90: 80 ff ff 78 78 78 78 78 78 06 00 fe 00 00 fe 00 ?..xxxxxx?.?..?. a0: 00 00 00 00 10 00 00 00 00 00 00 80 80 00 00 00 ....?......??... b0: 00 00 00 04 00 00 00 00 00 00 04 00 00 00 00 00 ...?......?..... c0: 00 04 00 00 00 00 00 00 04 00 00 00 00 00 00 00 .?......?....... d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ e0: 00 00 00 00 00 00 02 00 00 00 00 00 00 00 00 00 ......?......... f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ |
i2c 写 i2cset ……