摘要: 安装 首先安装memory_profiler和psutil 在需要分析的函数前面添加装饰器@profile 运行call后的输出: Line Mem usage Increment Line Contents ============================================= 阅读全文
posted @ 2019-08-30 22:50 BRYANT_2019 阅读(748) 评论(0) 推荐(0) 编辑
摘要: 使用自定义装饰器测量时间 输出结果: 开始时间: 2019 08 30 22:22:01.881215 结束时间: 2019 08 30 22:22:02.816677 耗时: 0:00:00.935462 使用cProfile ncalls tottime percall cumtime perc 阅读全文
posted @ 2019-08-30 22:32 BRYANT_2019 阅读(680) 评论(0) 推荐(0) 编辑
摘要: 函数中使用全局变量 执行fun()后返回值为:500 a, b使用的是全局变量的值。 函数中覆盖全局变量 执行fun()后返回值为:50 a, b使用的是局部变量的值。 函数中修改改全局变量 执行fun()后返回值为:110 a使用的是全局变量a=100的值, b使用的是函数func修改后b的值10 阅读全文
posted @ 2019-08-30 22:15 BRYANT_2019 阅读(350) 评论(0) 推荐(1) 编辑
摘要: 断言语句的格式 test是一个表达式,表达式求值为 时引发AssertionError异常,msg是可选的异常消息。 运行test_assert( 10)程序将抛出异常: Traceback (most recent call last): File "M:/project/untitled1/te 阅读全文
posted @ 2019-08-30 11:14 BRYANT_2019 阅读(1718) 评论(0) 推荐(0) 编辑