https://github.com/tx7do/test_std_atomic
https://github.com/tx7do/test_std_atomic
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/tx7do/test_std_atomic
- Owner: tx7do
- License: mit
- Created: 2022-12-16T03:19:44.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-12-16T09:50:04.000Z (over 3 years ago)
- Last Synced: 2025-01-02T05:32:12.459Z (over 1 year ago)
- Language: C++
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 测试std::atomic
| 类型 | 结果 | 耗时 |
|-----|----------|------------|
| 不加锁 | 无 | 无 |
| 加锁 | 10000000 | 1157.28 ms |
| 原子 | 10000000 | 223.048 ms |
不加锁根本没有办法完成,Crash了。
使用原子操作明显比加锁操作要效率高。
## 参考资料
- [std::atomic 用法與範例](https://shengyu7697.github.io/std-atomic/)
- [C++11中的原子操作(atomic operation)](https://blog.csdn.net/yockie/article/details/8838686)