首页 > python的一段代码,看的不是很懂

python的一段代码,看的不是很懂

def _profiling(start, sql=''):
    t = time.time() - start
    if t > 0.1:
        logging.warning('[PROFILING] [DB] %s: %s' % (t, sql))
    else:
        logging.info('[PROFILING] [DB] %s: %s' % (t, sql))

#调用应该是这样
t = time.time()
_profiling(t)

#这个函数具体是干什么的

记录 sql 语句的执行时间,

如果执行时间大于 100ms 则记录为 warning 否则为 info。

【热门文章】
【热门文章】