同一个方法,加了virtual,通过父类去调用这个方法,和不加virtual调用,会占用更多时间?
方法:
/// <summary> /// 针对病种库或实验组的病例检索 /// </summary> public Virtual SearchResultViewModel SearchCaseView(int? groupId, int? sdId, string viewId, bool isAdv, string filterTree, string filterParas, string sysParamLoginUser, bool forAddingCase = false, bool forExport = false) { var searchResultReturn = _caseService.SearchCases(groupId, sdId, viewId, isAdv, filterTree, filterParas, sysParamLoginUser, forAddingCase, forExport); var result = new SearchResultViewModel(searchResultReturn.Model, searchResultReturn.IsSuccessful, searchResultReturn.FailureReason); result.GroupInMaxNum = searchResultReturn.GroupInMaxNum; result.operlogStr = searchResultReturn.operlogStr; return result; }
调用:
public ActionResult SearchCasesBySD(int sdid, string viewId, bool isAdv, string filterTree, string filterParas) { System.Diagnostics.Stopwatch logwatch = new System.Diagnostics.Stopwatch(); logwatch.Start(); var caseList = _service.SearchCaseView(null, sdid, viewId, isAdv, filterTree, filterParas, AuthenticatedUserName); logwatch.Stop(); caseList.operlogStr += (string.Format("--Action调用SearchCaseView,isAdv,{0},总耗时{1}毫秒,viewId,{2},结束时间{3} --\r\n", isAdv, logwatch.ElapsedMilliseconds, viewId, System.DateTime.Now.ToString())); }
方法 SearchCaseView加不加virtual关键词 所耗得时间相差 100毫秒左右。为什么?
拉风的咖菲猫
慕丝7291255
炎炎设计
相关分类