import time; #------------------------------------------------------------------------------ #init for calculate elapsed time def calcTimeStart(uniqueKey) : global gVal gVal['calTimeKeyDict'][uniqueKey] = time.time(); return #------------------------------------------------------------------------------ # to get elapsed time, before call this, should use calcTimeStart to init def calcTimeEnd(uniqueKey) : global gVal return time.time() - gVal['calTimeKeyDict'][uniqueKey];
例 2.3. calcTimeStart和calcTimeEnd的使用范例
calcTimeStart("export_head"); exportHead(blogInfoDic); gVal['statInfoDict']['exportHeadTime'] = calcTimeEnd("export_head");