Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Using iis logs for performance testing with visual studio
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 1.0.0.2
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: Comment
In 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 download
the sample solution I am demo-ing in the blog post.
Introduction
Performance 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. Walkthrough
1. Download and Install Log Parser from the Microsoft download Centre. You should see the LogParser.dll in the install folder, the default install location is
C: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 in
the 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 key
data 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.dll
5. Right click IISLogsToWebPerfTestEngine project and add a new classes – IISLogReader.cs
The IISLogReader class queries the iis logs using the log parser.
uigSse;
sn ytm
uigSse.olcin.eei;
sn ytmCletosGnrc
uigSse.et
sn ytmTx;
uigMUi;
sn Stl
uigLgur =MUi.oQeylsCas
sn oQey StlLgurCasls;
uigISoIptomt=MUi.OIS3IptotxCasls;
sn ILgnuFra StlCMIWCnuCnetlsCas
uigLgeode =MUi.Lgeode;
sn oRcrSt StlIoRcrst
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 !eode.tn()
{
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)
eode.ls(;
}
}
}
6. Connect the dots by adding the project reference ‘IisLogsToWebPerfTestEngine’ to ‘IisLogsToWebPerfTest’. Right click the ‘IisLogsToWebPerfTest’ project
and add a new class ‘WebTest1Coded.cs’
4. The WebTest1Coded.cs inherits from the WebTest class. By overriding the GetRequestMethod we can inject the log files to the IISLogReader class which uses
Log 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
uigSse.et
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 see
the 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. 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 PM
Comments 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 doesn't 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)