python用装饰器去对比type函数和isinstance函数运行时间

2019年3月29日00:14:30 发表评论 1,284 views

发现个好东西: 一个免费短链生成项目:“ https://www.isok.co”一个可以生成所有短链的服务,isok.co的这个含义能覆盖所有短链含义isok, 我试过了很不错,都可以试试

import time
str1 = 'aaaaa'
def run_timefunc(func):
    def new_func(*args,**kwargs):
        t0 = time.time()
        func()
        # back = func(*args,**kwargs)
        print('函数运行时间%s'%(time.time()-t0))
        return
    return new_func()
@run_timefunc
def com3():
    for i in range(0,10000000):
        type('aaa')
@run_timefunc
def com2():
    for i in range(0,10000000):
        isinstance('aaa',str)
com3()
com2()

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: