11 2021 档案

摘要:很多人做性能测试,吧print打开,吧log调到debug级别并使用了streamhandler,那就会疯狂打印到控制台。 打印控制台会影响代码性能吗?这是毫无疑问的,python print会严重影响python性能。 有很多人对分布式函数调度框架做性能测试,但在消费函数里面进行print并且框架 阅读全文
posted @ 2021-11-24 15:03 北风之神0509 阅读(3609) 评论(0) 推荐(0) 编辑
摘要:pip install sync2asyncio python 快速万能同步转异步语法。 使任意同步库快速变asyncio异步语法的方式 ,simple_run_in_executor 这是一个异步对象Asyncio的Future了,可以被await和异步任务编排。 await simple_run 阅读全文
posted @ 2021-11-23 18:24 北风之神0509 阅读(2236) 评论(0) 推荐(0) 编辑
摘要:0.项目目录说明,pythonpathdemo是这个项目的根目录,d1/d2/d3/m3.py 有一个fun3函数,d4/d5/run.py 里面导入和运行fun3函数,这种目录的python项目就很容易验证pythonpath作用了。 截图可以看出,pycahrm运行正确,cmd命令行却不行,vs 阅读全文
posted @ 2021-11-18 18:44 北风之神0509 阅读(872) 评论(0) 推荐(1) 编辑
摘要:return JSONObject.toJSONString(kafkaMsg, SerializerFeature.WriteMapNullValue); //需要这样才会显示出值为null的键值对,否则丢失键,下面的就不行 return kafkaMsg.toJSONString(); 阅读全文
posted @ 2021-11-16 17:36 北风之神0509 阅读(256) 评论(0) 推荐(0) 编辑
摘要:代码如下,先定义一个无限蒙蔽死循环消耗cpu的函数 f 在一台4核cpu的linux上,分别直接 单进程单线程跑f函数,4进程跑f函数,4线程跑f函数,2进程程跑f函数,3进程跑f函数,50进程跑f函数 from threading import Thread from multiprocessin 阅读全文
posted @ 2021-11-15 21:01 北风之神0509 阅读(340) 评论(2) 推荐(2) 编辑
摘要:一下代码使用官方进程池和线程池测试,运行10万次函数时间。 import time from concurrent.futures import ProcessPoolExecutor,ThreadPoolExecutor # import nb_log def f(x): pass if x%10 阅读全文
posted @ 2021-11-01 10:49 北风之神0509 阅读(1218) 评论(0) 推荐(1) 编辑

点击右上角即可分享
微信分享提示