2011-07-11 10 views
28

के लिए प्रोफ़ाइल समय प्रदर्शित कर रहा प्रतीत होता है मैंने अभी एमवीसी-मिनी-प्रोफाइलर (http://code.google.com/p/mvc-mini-profiler/) का उपयोग करना शुरू कर दिया है और मुझे लगता है कि यह कमाल है। हालांकि, इसका उपयोग करते समय मुझे कुछ अजीब व्यवहार मिल रहा है।मिनी एमवीसी प्रोफाइलर: प्रत्येक स्थैतिक संसाधन

मुझे आईआईएस 7.5 पर चल रही एक एएसपी.NET वेबफॉर्म साइट मिली है और कुछ कारणों से जब मैं प्रोफाइलर सक्षम के साथ एक पृष्ठ लोड करता हूं, मुझे केवल एएसपीएक्स पेज के लिए समय माप नहीं मिलता है, लेकिन मुझे यह भी मिलता है पृष्ठ पर यादृच्छिक सीएसएस और जेएस संसाधनों के लिए।

एएसपीएक्स प्रोफाइल सही तरीके से काम करता है, एसक्यूएल क्वेरी को सही तरीके से प्रोफाइल किया जा रहा है। हालांकि, जैसा कि चित्र दिखाता है, मुझे अन्य परिणामों का एक गुच्छा भी मिलता है जो स्थिर सीएसएस और जेएस फाइलों के परिणाम होते हैं। जहां तक ​​मैं कह सकता हूं, इन्हें आईआईएस द्वारा स्थिर रूप से पेश किया जा रहा है, इसलिए प्रोफाइलर कोड को इनके लिए भी नहीं बुलाया जाना चाहिए।

मेरी Global.asax के प्रासंगिक भागों हैं:

protected void Application_BeginRequest() 
    { 
     MiniProfiler profiler = null; 

     // might want to decide here (or maybe inside the action) whether you want 
     // to profile this request - for example, using an "IsSystemAdmin" flag against 
     // the user, or similar; this could also all be done in action filters, but this 
     // is simple and practical; just return null for most users. For our test, we'll 
     // profile only for local requests (seems reasonable) 
     profiler = MiniProfiler.Start(); 

     using (profiler.Step("Application_BeginRequest")) 
     { 
      // you can start profiling your code immediately 
     } 
    } 

    protected void Application_EndRequest() 
    { 
     MvcMiniProfiler.MiniProfiler.Stop(); 
    } 

    protected void Application_AuthenticateRequest(object sender, EventArgs e) 
    { 
     if (User == null || !User.Identity.IsAuthenticated) 
     { 
      MvcMiniProfiler.MiniProfiler.Stop(true); 
     } 
    } 

इस व्यवहार की उम्मीद है?

उत्तर

45

हाँ यह सही है लेकिन इन्हें फ़िल्टर करना बहुत आसान है।

परियोजना Source

void Application_Start(object sender, EventArgs e) 
{ 
    // Code that runs on application startup 

    // some things should never be seen 
    var ignored = MiniProfiler.Settings.IgnoredPaths.ToList(); 

    ignored.Add("WebResource.axd"); 
    ignored.Add("/Styles/"); 

    MiniProfiler.Settings.IgnoredPaths = ignored.ToArray(); 
} 

यह आपको को फ़िल्टर क्या आप देखना चाहते हैं या नहीं यह मैं क्या मेरी वेब अनुप्रयोग से बाहर कर दिया का एक नमूना मैं खोजने है जो कर रहा हूँ है की सुविधा देता है में नमूना कोड से लिया मेरे आवेदन के लिए काम कर रहे हैं

ignored.Add("WebResource.axd"); 
ignored.Add("ScriptResource.axd"); 
ignored.Add("/Styles/"); 
ignored.Add("/Images/"); 
ignored.Add(".js"); 
+0

मैं प्रोफाइलर की मेरी संस्करण को अद्यतन करने के लिए किया था, लेकिन यह काम किया है करने के लिए .... – growse

+0

एक बात मैं नवीनतम कोड के साथ देखा है वहाँ कुछ डिबग कोड है कि में और छोड़ दिया गया है है प्रकट होता है आईई के साथ कुछ मुद्दों का कारण बनता है। मैंने जारीकर्ता ट्रैकर अंक 53 –

+0

पर कोई समस्या लॉग कर दी है, मैं नजर रखूंगा - धन्यवाद। हमारे सभी देव क्रोम/एफएफ पर हैं, इसलिए मैं चिंतित नहीं हूं। – growse

1

आप वास्तव में इसे एक पंक्ति में डाल सकते हैं और स्लेश को भी छोड़ सकते हैं। इस तरह:

protected void Application_BeginRequest() 
    { 
     if (Request.IsLocal) 
     { 
      MiniProfiler.Start(); 
      MiniProfiler.Settings.IgnoredPaths = new[] { "static", "webresource.axd", "styles", "images" }; 
     } 
    } 
संबंधित मुद्दे