디버깅클래스도 좀 수정했다

디버깅클래스도 좀 수정했다

avatar
리탭
2024.08.29조회수 6회

데이터 10만개정도 처리하는데 세월아 네월아 하고있길래

아니도대체뭐가문제지 하고 구간마다 시간을 기록해서 더해서 합해서 어디서 차가막히는지 찾으려하는데

이걸 자주 반복하게되는 것 같아 이미 쓰던 디버깅에 도움을 주는 클래스를 좀 수정해 보았다

from datetime import datetime, timezone
import inspect
import time

def QDEBUG(comment, variable):
    qDebug = DEBUGREPORT()
    qDebug.GING = True
    qDebug.report(comment, variable)

class DEBUGREPORT:
    def __init__(self, GING=False, TEMP=False, timeCounterLabel=None):
        self.GING = GING # variable name can be DEBUG so that expression as DEBUG.GING == True can be used
        self.TEMP = TEMP
        self.ERR = "FLAG_ERROR_DEBUGREPORT"
        if timeCounterLabel == None:
            timeCounterLabel = inspect.currentframe().f_back.f_lineno
        self._timecounter = {timeCounterLabel: 0}
        self._lastRecordedTime = time.perf_counter()

    def timeMarker(self, flag_reset=False, timeCounterLabel=None):
        if flag_reset:
            self._timecounter = {}

        if timeCounterLabel == None:
            timeCounterLabel = inspect.currentframe().f_back.f_lineno
        # Get the current frame, then the caller's frame
        # Get the caller's line number
        currentTime = time.perf_counter()
        if timeCounterLabel in self._timecounter:
            ...

회원가입만 해도
이 글을 무료로 읽을 수 있어요.

이미 계정이 있으신가요?로그인하기
댓글 2
avatar
리탭
구독자 32명구독중 14명
알팀장님과 함께하는 즐거운 합법도박 라이프