maplestory_dpm_calc icon indicating copy to clipboard operation
maplestory_dpm_calc copied to clipboard

buff modifier 최적화

Open icepeng opened this issue 4 years ago • 0 comments

BuffSkillWrapper에 modifier가 변경되었는지 체크하는 dirty 변수 추가

get_buff_modifier 계산 시 모든 버프가 dirty = False면 캐싱된 mdf값을 사용

iadd 호출 횟수를 730393회 -> 30953회로 대폭 줄일 수 있음 (nightlord 1800초 기준)

example code

def get_buff_modifier(self) -> CharacterModifier:
    mdf = self._buffMdfPreCalc.copy()  # BuffModifier는 쿨타임이 없는 버프에 한해 캐싱하여 연산량을 감소시킵니다. 캐싱된
    calc_zip = self._buffMdfCalcZip
    dirty = False
    for buffwrp, st in calc_zip:
        if st and buffwrp.dirty:
            dirty = True

    if not dirty:
        return self._buffMdfCache
    
    for buffwrp, st in calc_zip:
        if st:
            buffwrp.dirty = False
            mdf += buffwrp.get_modifier()
            # print(buffwrp.skill.name, buffwrp.is_active(), buffwrp.get_modifier().pdamage_indep)

    self._buffMdfCache = mdf
    return mdf

icepeng avatar Dec 03 '20 10:12 icepeng