当前位置:网站首页>二、并发、测试笔记 青训营笔记
二、并发、测试笔记 青训营笔记
2022-07-07 03:40:00 【低调的骏马】
并发、单元测试课程笔记 | 青训营笔记
这是我参与「第三届青训营 -后端场」笔记创作活动的的第1篇笔记
并发
并发和并行
并发:在一个核的CPU中运行
并行:在多个核的CPU中运行
协程和线程
- 协程:用户态轻量级线程,KB级别
- 线程:内核态,可跑多个的协程,MB级别
协程的通信
channel(是否同步->消费和生产的效率不等)
Lock(并发安全)
sync包下的Mutex,加锁保证并发安全
WaitGroup
方法:
结构:
测试
单元测试
规则
assert(例子:assert.Equal()方法,快速比较判断测试结果)
覆盖率(
)<===“–cover”
依赖((mock机制)幂等、稳定==》打桩)
幂等:每一次测试运行都应该产生与之前一样的结果
Mockey Patch的作用域在Runtime,在运行时通过通过Go的unsafe包,将内存中函数的地址替换为运行时函数的地址。将待打桩函数或方法的实现跳转。
基准测试
测试程序运行的性能和CPU的损耗
ps:执行rand要消耗的时间比较长,因为rand为了保证全局的随机性和并发安全,持有了一把全局锁,因此推荐使用一种高性能随机数方法fastrand,牺牲了一定的数列一致性。
补充
登录两种形式区别
一、Cookie和Session
和端上进行交互的话一般是使用这种方式鉴权。
二、JWT+Token
不需要依赖一些存储,一般是后端直接解密。
一般在于服务器、http进行交互的话,使用JWT+token
消息队列应用场景
解决的问题主要都是隔离作用
使用场景:两种方法,如果是强依赖,就无法通过这种方式进行实现
如果是非强依赖,方法A是发布一个消息、事件,方法B是接收并消费这个事件去做异步的处理,这样的情况下使用消息队列,就能起到解耦的功能
强依赖,就无法通过这种方式进行实现
如果是非强依赖,方法A是发布一个消息、事件,方法B是接收并消费这个事件去做异步的处理,这样的情况下使用消息队列,就能起到解耦的功能
边栏推荐
- Differences between H5 architecture and native architecture
- Abnova membrane protein lipoprotein technology and category display
- Advanced level of C language (high level) pointer
- 修改Jupyter Notebook文件路径
- Several important steps to light up the display
- Stack Title: nesting depth of valid parentheses
- Use of completable future
- Initial experience of teambiion network disk (Alibaba cloud network disk)
- 机器人技术创新与实践旧版本大纲
- Reflection (II)
猜你喜欢
普通测试年薪15w,测试开发年薪30w+,二者差距在哪?
面试官:你都了解哪些开发模型?
深度学习花书+机器学习西瓜书电子版我找到了
抽絲剝繭C語言(高階)數據的儲存+練習
抽丝剥茧C语言(高阶)指针的进阶
Graduation design game mall
How does an enterprise manage data? Share the experience summary of four aspects of data governance
抽絲剝繭C語言(高階)指針的進階
Sqlmap tutorial (IV) practical skills three: bypass the firewall
Abnova membrane protein lipoprotein technology and category display
随机推荐
Communication of components
组件的嵌套和拆分
Multidisciplinary integration
Stack Title: nesting depth of valid parentheses
sql中对集合进行非空校验
抽丝剥茧C语言(高阶)指针进阶练习
How to model and simulate the target robot [mathematical / control significance]
How Oracle backs up indexes
Readonly read only
抽絲剝繭C語言(高階)指針的進階
Several important steps to light up the display
js小练习
L'étape avancée du pointeur de langage C (haut de gamme) pour l'enroulement des cocons
OOM(内存溢出)造成原因及解决方案
Docker compose start redis cluster
记一个并发规则验证实现
Wechat applet full stack development practice Chapter 3 Introduction and use of APIs commonly used in wechat applet development -- 3.10 tabbar component (I) how to open and use the default tabbar comp
Detailed explanation of neo4j installation process
$parent(获取父组件) 和 $root(获取根组件)
Flexible layout (II)