import time

def tm(*arg, **kwargs):
  def wrap_fun(fun):
    def wrap_arg(*arg, **kwargs):
      print time.time()

      fun(*arg, **kwargs)

      print time.time()
    return wrap_arg
  return wrap_fun

@tm()
def test(x,y):
  print "x+y=" + str(x+y)

@tm()
def test1():
  print "no args"

@tm()
def test2(str):
  print "args = " + str


test(23,34)
test1()
test2("sdfsdfsdjklfsdkf")

posted on 2016-07-29 18:02  John Liang  阅读(166)  评论(0编辑  收藏  举报