seo网站开发html交易网站设计实例
seo网站开发,html交易网站设计实例,营销型网站建设的好处,wordpress dashicons使用timeit模块进行速度测试,使用profile模块进行性能统计,使用dis模块进行字节码反汇编.下面的脚本演示了如何使用模块.从输出中注意到的一件事是函数调用的数量会影响整体性能(当然,字节码指令的数量也是如此).希望,(以及更多实验)应该为您提供有关如何提高功能效率的足够线索…使用timeit模块进行速度测试,使用profile模块进行性能统计,使用dis模块进行字节码反汇编.下面的脚本演示了如何使用模块.从输出中注意到的一件事是函数调用的数量会影响整体性能(当然,字节码指令的数量也是如此).希望,(以及更多实验)应该为您提供有关如何提高功能效率的足够线索.from timeit import timeitfrom cProfile import runctxfrom dis import disdef analyse(*args):victim detartratednumber 1000for func in args:print(%s % (# * 50))name func.__name__print(test: %s(%r): %r % (name, victim, func(victim)))code %s(%r) % (name, victim)duration timeit(code, from __main__ import %s % name, numbernumber)usec 1000000 * duration / numberprint(time: %s: %.2f usec/pass % (code, usec))runctx(code, globals(), locals())dis(func)def check_palin1(victim): check progressively inner chars x 0# len/2 is num of iter needed for guaranteewhile x (len(victim)/2):# on pass n, compare nth letter and nth to last letterif victim[x0] is victim[-(1x)]:# then increment the n counterx 1else:return Falsereturn Truedef check_palin2(victim): check first and last chars repeatedly tmp []for i in victim:# convert string into listtmp.append(i)# if 1 or 0 char left, palin is guaranteedwhile len(tmp) 1:# if the first and last characters are the same letterif tmp[0] is tmp[-1]:# remove them bothtmp.pop(0)tmp.pop(-1)else:return Falsereturn Truedef check_palin3(victim): reverse string and compare to original using a loop tmp # for every letterfor i in victim:# cat it to the beginning, not appendtmp i tmpreturn tmp victimdef check_palin4(victim): reverse string and compare to original using slice syntax return victim victim[::-1]analyse(check_palin1, check_palin2, check_palin3, check_palin4)输出##################################################test: check_palin1(detartrated): Truetime: check_palin1(detartrated): 3.80 usec/pass9 function calls in 0.000 secondsOrdered by: standard namencalls tottime percall cumtime percall filename:lineno(function)1 0.000 0.000 0.000 0.000 :1()1 0.000 0.000 0.000 0.000 test.py:20(check_palin1)6 0.000 0.000 0.000 0.000 {len}1 0.000 0.000 0.000 0.000 {method disable of _lsprof.Profiler objects}22 0 LOAD_CONST 1 (0)3 STORE_FAST 1 (x)24 6 SETUP_LOOP 72 (to 81) 9 LOAD_FAST 1 (x)12 LOAD_GLOBAL 0 (len)15 LOAD_FAST 0 (victim)18 CALL_FUNCTION 121 LOAD_CONST 2 (2)24 BINARY_DIVIDE25 COMPARE_OP 0 (28 POP_JUMP_IF_FALSE 8026 31 LOAD_FAST 0 (victim)34 LOAD_FAST 1 (x)37 LOAD_CONST 1 (0)40 BINARY_ADD41 BINARY_SUBSCR42 LOAD_FAST 0 (victim)45 LOAD_CONST 3 (1)48 LOAD_FAST 1 (x)51 BINARY_ADD52 UNARY_NEGATIVE53 BINARY_SUBSCR54 COMPARE_OP 8 (is)57 POP_JUMP_IF_FALSE 7328 60 LOAD_FAST 1 (x)63 LOAD_CONST 3 (1)66 INPLACE_ADD67 STORE_FAST 1 (x)70 JUMP_ABSOLUTE 930 73 LOAD_GLOBAL 1 (False)76 RETURN_VALUE77 JUMP_ABSOLUTE 9 80 POP_BLOCK31 81 LOAD_GLOBAL 2 (True)84 RETURN_VALUE##################################################test: check_palin2(detartrated): Truetime: check_palin2(detartrated): 10.57 usec/pass30 function calls in 0.000 secondsOrdered by: standard namencalls tottime percall cumtime percall filename:lineno(function)1 0.000 0.000 0.000 0.000 :1()1 0.000 0.000 0.000 0.000 test.py:33(check_palin2)6 0.000 0.000 0.000 0.000 {len}11 0.000 0.000 0.000 0.000 {method append of list objects}1 0.000 0.000 0.000 0.000 {method disable of _lsprof.Profiler objects}10 0.000 0.000 0.000 0.000 {method pop of list objects}35 0 BUILD_LIST 03 STORE_FAST 1 (tmp)36 6 SETUP_LOOP 27 (to 36)9 LOAD_FAST 0 (victim)12 GET_ITER 13 FOR_ITER 19 (to 35)16 STORE_FAST 2 (i)38 19 LOAD_FAST 1 (tmp)22 LOAD_ATTR 0 (append)25 LOAD_FAST 2 (i)28 CALL_FUNCTION 131 POP_TOP32 JUMP_ABSOLUTE 13 35 POP_BLOCK40 36 SETUP_LOOP 75 (to 114) 39 LOAD_GLOBAL 1 (len)42 LOAD_FAST 1 (tmp)45 CALL_FUNCTION 148 LOAD_CONST 1 (1)51 COMPARE_OP 4 ()54 POP_JUMP_IF_FALSE 11342 57 LOAD_FAST 1 (tmp)60 LOAD_CONST 2 (0)63 BINARY_SUBSCR64 LOAD_FAST 1 (tmp)67 LOAD_CONST 3 (-1)70 BINARY_SUBSCR71 COMPARE_OP 8 (is)74 POP_JUMP_IF_FALSE 10644 77 LOAD_FAST 1 (tmp)80 LOAD_ATTR 2 (pop)83 LOAD_CONST 2 (0)86 CALL_FUNCTION 189 POP_TOP45 90 LOAD_FAST 1 (tmp)93 LOAD_ATTR 2 (pop)96 LOAD_CONST 3 (-1)99 CALL_FUNCTION 1102 POP_TOP103 JUMP_ABSOLUTE 3947 106 LOAD_GLOBAL 3 (False)109 RETURN_VALUE110 JUMP_ABSOLUTE 39 113 POP_BLOCK48 114 LOAD_GLOBAL 4 (True)117 RETURN_VALUE##################################################test: check_palin3(detartrated): Truetime: check_palin3(detartrated): 2.77 usec/pass3 function calls in 0.000 secondsOrdered by: standard namencalls tottime percall cumtime percall filename:lineno(function)1 0.000 0.000 0.000 0.000 :1()1 0.000 0.000 0.000 0.000 test.py:50(check_palin3)1 0.000 0.000 0.000 0.000 {method disable of _lsprof.Profiler objects}52 0 LOAD_CONST 1 ()3 STORE_FAST 1 (tmp)54 6 SETUP_LOOP 24 (to 33)9 LOAD_FAST 0 (victim)12 GET_ITER 13 FOR_ITER 16 (to 32)16 STORE_FAST 2 (i)56 19 LOAD_FAST 2 (i)22 LOAD_FAST 1 (tmp)25 BINARY_ADD26 STORE_FAST 1 (tmp)29 JUMP_ABSOLUTE 13 32 POP_BLOCK57 33 LOAD_FAST 1 (tmp)36 LOAD_FAST 0 (victim)39 COMPARE_OP 2 ()42 RETURN_VALUE##################################################test: check_palin4(detartrated): Truetime: check_palin4(detartrated): 0.65 usec/pass3 function calls in 0.000 secondsOrdered by: standard namencalls tottime percall cumtime percall filename:lineno(function)1 0.000 0.000 0.000 0.000 :1()1 0.000 0.000 0.000 0.000 test.py:59(check_palin4)1 0.000 0.000 0.000 0.000 {method disable of _lsprof.Profiler objects}61 0 LOAD_FAST 0 (victim)3 LOAD_FAST 0 (victim)6 LOAD_CONST 1 (None)9 LOAD_CONST 1 (None)12 LOAD_CONST 2 (-1)15 BUILD_SLICE 318 BINARY_SUBSCR19 COMPARE_OP 2 ()22 RETURN_VALUE
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/pingmian/88838.shtml
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!