當前位置: 首頁>>代碼示例>>Python>>正文


Python AdmitLogging.timing方法代碼示例

本文整理匯總了Python中admit.util.AdmitLogging.AdmitLogging.timing方法的典型用法代碼示例。如果您正苦於以下問題:Python AdmitLogging.timing方法的具體用法?Python AdmitLogging.timing怎麽用?Python AdmitLogging.timing使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在admit.util.AdmitLogging.AdmitLogging的用法示例。


在下文中一共展示了AdmitLogging.timing方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: end

# 需要導入模塊: from admit.util.AdmitLogging import AdmitLogging [as 別名]
# 或者: from admit.util.AdmitLogging.AdmitLogging import timing [as 別名]
 def end(self):
     t0 = self.init
     t1 = self.time()
     dt = t1 - t0
     if self.report:
         logging.timing("%s END " % self.label + str(dt))
     return dt
開發者ID:teuben,項目名稱:admit,代碼行數:9,代碼來源:utils.py

示例2: get_mem

# 需要導入模塊: from admit.util.AdmitLogging import AdmitLogging [as 別名]
# 或者: from admit.util.AdmitLogging.AdmitLogging import timing [as 別名]
    def get_mem(self):
        """ Read memory usage info from /proc/pid/status
            Return Virtual and Resident memory size in MBytes.
        """
        global ostype
        
        if ostype == None:
            ostype = os.uname()[0].lower()
            logging.info("OSTYPE: %s" % ostype)
            
        scale = {'MB': 1024.0}
        lines = []
        try:
            if ostype == 'linux':
                proc_status = '/proc/%d/status' % os.getpid()          # linux only
                # open pseudo file  /proc/<pid>/status
                t = open(proc_status)
                # get value from line e.g. 'VmRSS:  9999  kB\n'
                for it in t.readlines():
                    if 'VmSize' in it or 'VmRSS' in it :
                        lines.append(it)
                t.close()
            else:
                proc = subprocess.Popen(['ps','-o', 'rss', '-o', 'vsz', '-o','pid', '-p',str(os.getpid())],stdout=subprocess.PIPE)
                proc_output = proc.communicate()[0].split('\n') 
                proc_output_memory = proc_output[1]
                proc_output_memory = proc_output_memory.split()
                
                phys_mem = int(proc_output_memory[0])/1204 # to MB 
                virtual_mem = int(proc_output_memory[1])/1024 
                
        except (IOError, OSError):
            if self.report:
                logging.timing(self.label + " Error: cannot read memory usage information.")

            return np.array([])

        # parse the two lines
    
        mem = {}
        if(ostype != 'darwin'):
            for line in lines:
                words = line.strip().split()
            #print words[0], '===', words[1], '===', words[2]
                
            # get rid of the tailing ':'
                key = words[0][:-1]

            # convert from KB to MB
                scaled = float(words[1]) / scale['MB']
                mem[key] = scaled
        else:
            mem['VmSize'] = virtual_mem
            mem['VmRSS']  = phys_mem


        return np.array([mem['VmSize'], mem['VmRSS']])
開發者ID:teuben,項目名稱:admit,代碼行數:59,代碼來源:utils.py

示例3: __init__

# 需要導入模塊: from admit.util.AdmitLogging import AdmitLogging [as 別名]
# 或者: from admit.util.AdmitLogging.AdmitLogging import timing [as 別名]
 def __init__(self, label=".", report=True):
     self.start = self.time()
     self.init = self.start
     self.label = label
     self.report = report
     self.dtimes = []
     dt = self.init - self.init
     if self.report:
         logging.timing("%s ADMIT " % self.label + str(self.start))
         logging.timing("%s BEGIN " % self.label + str(dt))
開發者ID:teuben,項目名稱:admit,代碼行數:12,代碼來源:utils.py

示例4: tag

# 需要導入模塊: from admit.util.AdmitLogging import AdmitLogging [as 別名]
# 或者: from admit.util.AdmitLogging.AdmitLogging import timing [as 別名]
    def tag(self, mytag):

        t0 = self.start
        t1 = self.time()
        dt = t1 - t0

        # get memory usage (Virtual and Resident) info
        mem = self.get_mem()
        if mem.size != 0 :
            dt = np.append(dt, mem)

        self.dtimes.append((mytag, dt))
        self.start = t1
        if self.report:
            logging.timing("%s " % self.label + mytag + "  " + str(dt))
        return dt
開發者ID:teuben,項目名稱:admit,代碼行數:18,代碼來源:utils.py

示例5: test_timing

# 需要導入模塊: from admit.util.AdmitLogging import AdmitLogging [as 別名]
# 或者: from admit.util.AdmitLogging.AdmitLogging import timing [as 別名]
    def test_timing(self):
        msg = "unit_test_timing_message"
        Alogging.timing(msg)
 
        found = False
        r = open(self.logfile, 'r')
        for line in r.readlines():
            if msg in line:
                if(self.verbose):
                    print "\nFound message > ", found
  
                found = True
                r.close()
                break
  
        self.assertTrue(found)
開發者ID:teuben,項目名稱:admit,代碼行數:18,代碼來源:unittest_AdmitLogging.py

示例6: show

# 需要導入模塊: from admit.util.AdmitLogging import AdmitLogging [as 別名]
# 或者: from admit.util.AdmitLogging.AdmitLogging import timing [as 別名]
 def show(self):
     if self.report:
         for r in self.dtimes:
             logging.timing("%s " % self.label + str(r[0]) + "  " + str(r[1]))
     return self.dtimes
開發者ID:teuben,項目名稱:admit,代碼行數:7,代碼來源:utils.py


注:本文中的admit.util.AdmitLogging.AdmitLogging.timing方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。