class Person(metaclass=decorateAll(tracer(timer(label='**')))):
    def __init__(self, name, pay):
        self.name = name
        self.pay = pay

    def giveRaise(self, percent):
        self.pay *= (1.0 + percent)

    def lastName(self):
        return self.name.split()[-1]
Пример #2
0
 def __new__(meta, classname, supers, classdict):
     for attr, attrval in classdict.items():
         if type(attrval) is FunctionType:
             print(attr, attrval)
             classdict[attr] = tracer(attrval)
     return type.__new__(meta, classname, supers, classdict)
Пример #3
0
 def __new__(meta, classname, supers, classdict):
     for attr, attrval in classdict.items():
         if type(attrval) is FunctionType:  # Method?
             classdict[attr] = tracer(attrval)  # Decorate it
     return type.__new__(meta, classname, supers, classdict)  # Make class
Пример #4
0
 def __new__(meta, classname, supers, classdict):
     for attr, attrval in classdict.items():
         if type(attrval) is FunctionType:  # 메서드?
             classdict[attr] = tracer(attrval)  # 데코레이션할 것
     return type.__new__(meta, classname, supers, classdict)  # 클래스 생성
Пример #5
0
print('%.5f' % Person.__init__.alltime)
print('%.5f' % Person.giveRaise.alltime)
print('%.5f' % Person.lastName.alltime)


# py -3 decoall-deco-any2.py 
# @@__init__: 0.00001, 0.00001
# @@__init__: 0.00001, 0.00001
# Bob Smith Sue Jones
# @@giveRaise: 0.00002, 0.00002
# 110000.00
# @@lastName: 0.00002, 0.00002
# @@lastName: 0.00002, 0.00004
# Smith Jones
# ----------------------------------------
# 0.00001
# 0.00002
# 0.00004


@decorateAll(tracer(timer(label='@@')))    # timer를 적용하는 것을 추적
class Person:

@decorateAll(tracer)                       # onCall 래퍼를 추적, 메서드의 시간을 측정
@decorateAll(timer(label='@@'))
class Person:

@decorateAll(timer(label='@@'))
@decorateAll(tracer)                       # onCall 래퍼의 시간 측정, 메서드를 추적
class Person:
Пример #6
0
 def __new__(meta, classname, supers, classdict):
     for attr, attrval in classdict.items():
         if type(attrval) is FunctionType:  # Method?
             classdict[attr] = tracer(attrval)  # Decorate it
     return type.__new__(meta, classname, supers, classdict)  # Make class