1 Star 4 Fork 1

HssinLaw/TControl

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
benchmarks.py 1.43 KB
一键复制 编辑 原始数据 按行查看 历史
ljcloud 提交于 2020-09-01 20:10 +08:00 . 项目从github迁移到gitee
import timeit
# run step, impulse and ramp
def run1():
r1 = timeit.timeit("tc.step(system, np.linspace(0, 10, 1000),plot=False)",
"import tcontrol as tc;import numpy as np;"
"system = tc.tf([5, 25, 30], [1, 6, 10, 8])", number=100)
r2 = timeit.timeit("tc.impulse(system, np.linspace(0, 10, 1000),plot=False)",
"import tcontrol as tc;import numpy as np;"
"system = tc.tf([5, 25, 30], [1, 6, 10, 8])", number=100)
r3 = timeit.timeit("tc.ramp(system, np.linspace(0, 10, 1000), plot=False)",
"import tcontrol as tc;import numpy as np;"
"system = tc.tf([5, 25, 30], [1, 6, 10, 8])", number=100)
print("step: {0:.5f} ms impulse: {0:.5f} ms ramp: {0:.5f} ms".format(r1*10, r2*10,
r3*10))
# run rlocus
def run2():
timer = timeit.Timer(
"rlocus(system, xlim=[-5, 0.5], plot=False)",
"from tcontrol import tf, rlocus; system = tf([0.5, 1], [0.5, 1, 1])")
r1 = timer.timeit(100)
print("{0:.5f} ms\n".format(r1*10))
# run bode
def run3():
timer = timeit.Timer("tc.bode(system, plot=False)",
"import tcontrol as tc; system = tc.zpk([], [0, -1, -2], 2)")
r1 = timer.timeit(100)
print("{0:.5f} ms\n".format(r1*10))
if __name__ == "__main__":
run1()
run2()
run3()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/houxinluo/TControl.git
git@gitee.com:houxinluo/TControl.git
houxinluo
TControl
TControl
master

搜索帮助