def countinfo(func): def funcNew(*args, **kwargs): import os, time, psutil _count_fname = func.__name__ _count_pid = os.getpid() _count_ps = psutil.Process(_count_pid) _count_smeno = _count_ps.memory_full_info().uss/1024 print('*' * 64) print("\033[1;32m" + 'Running...' + "\033[0m") print("\033[0;31m" + 'Function:' + '<' + _count_fname + '>' + '\tPid:' + str(_count_pid) + "\033[0m", end='\t') _count_stime = time.time() _count_ret = func(*args, **kwargs) _count_etime = time.time() _count_emeno = _count_ps.memory_full_info().uss / 1024 print("\033[0;31m" + 'Run(unit:ms):' + str(int((_count_etime - _count_stime)*1000)) + '\t' + 'Men(unit:KB):' + str(int(_count_emeno - _count_smeno)) + "\033[0m") print('*' * 64) return _count_ret return funcNew