Using iis logs for performance testing with visual studio


Published on

1 Like
    Are you sure you want to  Yes  No
    Your message goes here
  • March 2017 calendar very good
    Are you sure you want to  Yes  No
    Your message goes here
  • nice bro
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Using iis logs for performance testing with visual studio

  1. 1. TARUN ARORA Website Tarun Arora is a Microsoft Certified professional developer for Enterprise Applications. He has extensively travelled around the world gaining experience learning and working in culturally diverse teams. Tarun has over 5 years of experience developing Energy Trading & Risk Management solutions for leading Trading & Banking Enterprises. His passion for technology has earned him the Microsoft Community Contributor and Microsoft MVP Award. MY RECENT POSTS How to undelete files in TFS Quartz.Net Windows Service Configure Logging Quartz.Net Writing your first Hello World Job Install Quartz.Net as a windows service and Test installation Webmatrix The Site has Stopped Fix MY OTHER POSTS TFS API Change WorkItem CreatedDate And ChangedDate To Historic Dates New features in TFS Demo Setup TFS API Add Favorites programmatically IntelliTrace collector error Some or all identity references could not be translated Get your TFS 2012 task board demo ready in under 1 minute Set up a TFS Server/Service demo environment in less than 1 minute now! Geeks with Blogs acquired by Watson Technology Group Pizza and IntelliTrace at NextGenUG on 16 and 23 October 2012 VS2012 Launch Event – Combating Bugs And Poor Performance In Production VS2012 Coded UI Test closes browser by default TEST Tarun Arora Visual Studio ALM MVP<< Visual Studio Load Testing using Windows Azure | Home | Where did I write that code ? >>Using IIS Logs for Performance Testing with Visual Studio share: CommentIn this blog post I’ll show you how you can play back the IIS Logs in Visual Studio to automatically generate the web performance tests. You can also downloadthe sample solution I am demo-ing in the blog post.IntroductionPerformance testing is as important for new websites as it is for evolving websites. If you already have your website running in production you could mine the information available in IIS logs to analyse the dense zones (most used pages) and performance test those pages rather than wasting time testing & tuning the least used pages in your application. What are IIS Logs To help with server use and analysis, IIS is integrated with several types of log files. These log file formats provide information on a range of websites and specific statistics, including Internet Protocol (IP) addresses, user information and site visits as well as dates, times and queries. If you are using IIS 7 and above you will find the log files in the following directory C:InterpubLogs
  2. 2. Walkthrough1. Download and Install Log Parser from the Microsoft download Centre. You should see the LogParser.dll in the install folder, the default install location isC:Program Files (x86)Log Parser 2.2. LogParser.dll gives us a library to query the iis log files programmatically. By the way if you haven’t used Log Parser inthe past, it is a is a powerful, versatile tool that provides universal query access to text-based data such as log files, XML files and CSV files, as well as keydata sources on the Windows operating system such as the Event Log, the Registry, the file system, and Active Directory. More details…2. Create a new test project in Visual Studio. Let’s call it IISLogsToWebPerfTestDemo.3. Delete the UnitTest1.cs class that gets created by default. Right click the solution and add a project of type class library, name it,IISLogsToWebPerfTestEngine. Delete the default class Program.cs that gets created with the project.4. Under the IISLogsToWebPerfTestEngine project add a reference to Microsoft.VisualStudio.QualityTools.WebTestFramework – c:Program Files (x86)Microsoft Visual Studio 10.0Common7IDEPublicAssembliesMicrosoft.VisualStudio.QualityTools.WebTestFramework.dll LogParser also called MSUtil - c:userstaroradocumentsvisual studio 2010ProjectsIisLogsToWebPerfTestIisLogsToWebPerfTestEngineobjDebugInterop.MSUtil.dll5. Right click IISLogsToWebPerfTestEngine project and add a new classes – IISLogReader.csThe IISLogReader class queries the iis logs using the log parser. uigSse; sn ytm uigSse.olcin.eei; sn ytmCletosGnrc sn ytmTx; uigMUi; sn Stl uigLgur =MUi.oQeylsCas sn oQey StlLgurCasls; uigISoIptomt=MUi.OIS3IptotxCasls; sn ILgnuFra StlCMIWCnuCnetlsCas uigLgeode =MUi.Lgeode; sn oRcrSt StlIoRcrst
  3. 3. uigMcootVsaSui.etol.eTsig sn irsf.iultdoTsTosWbetn; uigSse.igotc; sn ytmDansis nmsaeIsosoePrTsEgn aepc iLgTWbefetnie { / B mkn ueo lgpre i i psil t qeyteislguigslc qeis / y aig s f o asr t s osbe o ur h i o sn eet ure pbi casISoRae ulc ls ILgedr { piaesrn _iLgah rvt tig isoPt; pbi ISoRae(tigisoPt) ulc ILgedrsrn iLgah { _iLgah=isoPt; isoPt iLgah } pbi InmrbeWbeteus>Gteuss) ulc Eueal<eTsRqet eRqet( { Lgur lgur =nwLgur(; oQey oQey e oQey) ISoIptomtisnuFra =nwISoIptomt) ILgnuFra iIptomt e ILgnuFra(; / cretyteeclmsgv u sfin ifraint cntuttewbts rqet / urnl hs oun ie s ufet nomto o osrc h e et euss srn qey=@SLC si,spr,c-ehd c-r-tm c-r-ur FO "+_iLgah tig ur "EET -p -ot smto, suise, suiqey RM isoPt; Lgeode rcrSt=lgur.xct(ur,isnuFra) oRcrSt eode oQeyEeueqey iIptomt; / Apyabto tasomto / pl i f rnfrain wie(rcrStaEd) hl ! { IoRcr rcr =rcrStgteod) Lgeod eod eode.eRcr(; i (eodgtauE(c-ehd)TSrn( = "E" f rcr.eVlex"smto".otig) = GT) { srn sre =rcr.eVlex"-p)TSrn(; tig evr eodgtauE(si".otig) srn pt =rcr.eVlex"suise".otig) tig ah eodgtauE(c-r-tm)TSrn(; srn qeytig=rcr.eVlex"suiqey)TSrn(; tig ursrn eodgtauE(c-r-ur".otig) SrnBidrulule =nwSrnBidr) tigule rBidr e tigule(; ulule.ped"tp/"; rBidrApn(ht:/) ulule.pedsre) rBidrApn(evr; ulule.pedpt) rBidrApn(ah; i (Srn.sulrmt(ursrn) f !tigINlOEpyqeytig) { ulule.ped""; rBidrApn(?) ulule.pedqeytig; rBidrApn(ursrn) } / Yucudmk sbtttosb itouigprmtrzdwbtss / o ol ae usiuin y nrdcn aaeeie e et. Wbeteus rqet=nwWbeteus(rBidrTSrn() eTsRqet eus e eTsRqetulule.otig); DbgWieierqetUlihurSrn) eu.rtLn(eus.rWtQeytig; yedrtr rqet il eun eus; } rcrStmvNx(; eode.oeet) } CnoeWieie"Ta i!Coigterae"; osl.rtLn( hts t lsn h edr) rcrStcoe); } } }6. Connect the dots by adding the project reference ‘IisLogsToWebPerfTestEngine’ to ‘IisLogsToWebPerfTest’. Right click the ‘IisLogsToWebPerfTest’ projectand add a new class ‘WebTest1Coded.cs’
  4. 4. The WebTest1Coded.cs inherits from the WebTest class. By overriding the GetRequestMethod we can inject the log files to the IISLogReader class which usesLog parser to query the log file and extract the web requests to generate the web test request which is yielded back for play back when the test is run. nmsaeIsosoePrTs aepc iLgTWbefet { uigSse; sn ytm uigSse.olcin.eei; sn ytmCletosGnrc sn ytmTx; uigMcootVsaSui.etol.eTsig sn irsf.iultdoTsTosWbetn; uigMcootVsaSui.etol.eTsigRls sn irsf.iultdoTsTosWbetn.ue; uigIsosoePrTsEgn; sn iLgTWbefetnie / Ti casi acddwbpromnets ipeetto,ta sml pse / hs ls s oe e efrac et mlmnain ht ipy ass / tept o teislg t teIsoRae caswihde tehay / h ah f h i os o h iLgedr ls hc os h ev / lfigo raigtecnet o telgfl adcnetn te t tss / itn f edn h otns f h o ie n ovrig hm o et. / Yucudhv mlil sc cassta ihrtfo Wbetadipeet / o ol ae utpe uh lse ht nei rm eTs n mlmn / GteusEueao Mto adps dfen lgflsfrdfeettss / eRqetnmrtr ehd n as ifrt o ie o ifrn et. pbi casWbetCdd:Wbet ulc ls eTs1oe eTs { pbi WbetCdd) ulc eTs1oe( { ti.rAtetct =tu; hsPeuhniae re } pbi oerd InmrtrWbeteus>GteusEueao( ulc vrie Eueao<eTsRqet eRqetnmrtr) { / sbttt tehglgtdpt wt tept o teislgfl / usiue h ihihe ah ih h ah f h i o ie ISoRae rae =nwISoRae(":DmiLg.o"; ILgedr edr e ILgedr@Ceoiso1lg) frah(eTsRqetrqeti rae.eRqet() oec Wbeteus eus n edrGteuss) { yedrtr rqet il eun eus; } } } }7. Its time to fire the test off and see the iis log playback as a web performance test. From the Test menu choose Test View Window you should be able to seethe WebTest1Coded test show up. Highlight the test and press Run selection (you can also debug the test in case you face any failures during test execution).
  5. 5. 8. Optionally you can create a Load Test by keeping ‘WebTest1Coded’ as the base test.Conclusion You have just helped your testing team, you now have become the coolest developer in your organization! Jokes apart, log parser and web performance test together allow you to save a lot of time by not having to worry about what to test or even worrying about how to record the test. If you haven’t already, download the solution from here. You can take this to the next level by using LogParser to extract the log files as part of an end of day batch to a database. See the usage trends by user this solution over a longer term and have your tests consume the web requests now stored in the database to generate the web performance tests. If you like the post, don’t forget to share … Keep RocKiNg!Print | posted on Wednesday, July 04, 2012 6:58 PMComments on this post: Using IIS Logs for Performance Testing with Visual Studio# re: Using IIS Logs for Performance Testing with Visual Studio One important thing you are missing here is that if you are using VS2010 the WebTestFramework.dll is only installed with VS2010 Ultimate, not Pro or Premium. This will save anyone the effort that is interested but doesnt have ultimate. You could copy the binaries from an ultimate machine but that would only allow you to complie the project but not run it. Left by Kevin Scharnhorst on Jul 05, 2012 10:40 PM# re: Using IIS Logs for Performance Testing with Visual Studio Yes that is correct Kevin. Web Performance Testing and Load testing is only supported out of Visual Studio Ultimate. Left by Tarun Arora on Jul 05, 2012 11:04 PM# re: Using IIS Logs for Performance Testing with Visual Studio Frankly, I love your blog. I met by chance. But now I am every day and I think I watched everything! Thank you very much anyway good luck Left by tirage tarot gratuitement on Jul 12, 2012 3:00 PM Your comment: Title: re: Using IIS Logs for Performance Testing with Visual Studio Name: Email: (never displayed)
  6. 6. (will show your gravatar) Website: Comment: Allowed tags: blockquote, a, strong, em, p, u, strike, super, sub, code Enter the code shown above Post Comment Copyright © Tarun Arora | Pow ered by: | Join freePOPULAR POSTS ON GEEKS WITH BLOGSFixing the "Microsoft Bus Driver" error message when installing a RealTek sound cardCISCO VPN Client Software on Windows VistaVisual Studio 2008 Debugging Tricks – Multi-Threaded DebuggingChanging your hosts file in VistaMsMpEng.exe is the nugget draining my CPU...Windows 7 Desktop GadgetsHOWTO: Print to a USB Printer from DOS in Windows XPHow to make a transparent background/selection on an image using GIMPHow to set the windows path in Windows 7Loading pages in IFRAME dynamically from codebehind - ASP.NETRELATED POSTS ON GEEKS WITH BLOGSVS2010 crashes when opening a vsp generated using VS 2012Fix for Failed to load results from the load test results storePresenting to KolkataGeeks Harnessing the cloud for Performance TestingVisual Studio Load Testing using Windows AzurePPT Leveraging Azure for Performance TestingPart 3–Load Testing In the Cloud Automating Test Rig DeploymentPart 2–Load Testing In The Cloud
  7. 7. Part 1 - Load Testing In The CloudLoad and Web Performance Testing using Visual Studio Ultimate 2010-Part 3Load and Web Performance Testing using Visual Studio Ultimate 2010-Part 2POST CATEGORIES TfsDeployer TFS2010 vNext Visual Studio Next Power Tools TFS API TFS SDK TFS Utilties Personal TfsAzure TfsService TfsPreview Tfs2012 TfsTAP MTM Branching & Merging SDET Web Performance Testing Load Testing Load Testing TFS Troubleshooting Azure TestingTours HostedTfs IE Migration ALMing in Hinglish Quartz.Net TBM ALMRangers ALM TfsDemoSetup WebMatrixARCHIVES November, 2012 (5) October, 2012 (9) September, 2012 (6) August, 2012 (5) July, 2012 (6) June, 2012 (2) May, 2012 (2) April, 2012 (4) March, 2012 (3) January, 2012 (4) December, 2011 (5) November, 2011 (7) October, 2011 (6) September, 2011 (7) August, 2011 (3) July, 2011 (7) June, 2011 (6) May, 2011 (3) April, 2011 (1)