[prev in list] [next in list] [prev in thread] [next in thread] 

List:       htmlunit-user
Subject:    Re: [Htmlunit-user] Does HTMLUnit has any caching?
From:       Marc Guillemot <mguillemot () yahoo ! fr>
Date:       2013-08-27 14:11:50
Message-ID: 521CB3A6.4080101 () yahoo ! fr
[Download RAW message or body]

Hi,

if I correctly remember, the Cache is synchronized internally therefore 
you can share it among different WebClient instances without any 
problem. Take care to configure its size to be large enough to have a 
chance to help.

Cheers,
Marc.
-- 
HtmlUnit support & consulting from the source
Blog: http://mguillem.wordpress.com

Le 08/08/2013 21:35, sridhar kura a écrit :
> Thanks for the detailed explanation Ronald.
>
> Yes, I'm creating a new WebClient for every test. So "N" requests will
> create "N" Webclient's.
>
>   Trying to understand how I can re-use the objects(mainly css and
> javascript) which were created in the first request(for a given page URL)?
>
> As per my profiling css and javascript parsing takes most of the time.
> So I can save the good amount of time if I re-use the objects which are
> created earlier.
>
> So if I do in the following way will HTMLUnit re-uses the objects which
> are created earlier for a given page URL?
>
>   Lets consider 100 requests as below:
>
> //Single Thread
>
> {
>
> BrowserVersion bv = BrowserVersion.FIREFOX_17;
> WebClient wc = new WebClient(bv, env);
>
>   for( RequestCount < 100 ) {
>
> //Thread Pool Max thread count 20
>
> {
>
> -wc.closeAllWindows()
>
> - Create Page
> -Process page
>
> - Submit page
>
> }
>
> }
>
> }
>
>
> Thanks,
>
> Sridhar
>
>
>
>
> On Thu, Aug 8, 2013 at 4:32 PM, Ronald Brill <rbri@rbri.de
> <mailto:rbri@rbri.de>> wrote:
>
>     Sridhar,
>
>     i'm still not sure that i got your point.
>
>      >        BrowserVersion bv = BrowserVersion.FIREFOX_17;
>      >        this.webClient = new WebClient(bv, env);
>      >       -  Creating HTMLPage with the given URL
>      >       -  Processing the page
>      >       - Submitting the Page.
>
>     Looks for me like you create a new WebClient for every test run (so
>     in the end 100.000 times).
>     My suggestion is to do it ony once for evey thread you use (so if
>     you have only one thread you have only one web client).
>
>     wc.closeAllWindows() does more or less what the name suggests; it
>     closes all WebClient windows; think about it like reseting your
>     WebClient to the initial state.
>     So wc.closeAllWindows() refreshes nothing it does the opposide. The
>     window that hold your page will be closed, the page is gone and your
>     next test cycle starts with a new window.
>
>     With wc.getPage("http://somwhere.com") the WebClient will
>     automatically generate a new window (like a new tab in FF), retrieve
>     the page html and assign the page to the newly created window.
>     Your further steps have to work with this new window/page. I gess
>     you will find some fields, fill them with text and press the submit
>     button. Then you usually check the result and you are done with
>     your test cycle.
>
>              RBRi
>
>
>
>     On Thu, 8 Aug 2013 15:23:00 +0530 sridhar kura wrote:
>      >
>      >Thank you Ronald I'm also planning to do the same but I was bit
>     concerned
>      >what if  same form data (which was cached by browser for first
>     request)  is
>      >submitted multiple times?
>      >
>      >Can you please confirm if wc.closeAllWindows() will refresh the page?
>      >
>      >Thanks,
>      >Sridhar
>      >
>      >
>      >On Thu, Aug 8, 2013 at 3:06 PM, Ronald Brill <rbri@rbri.de
>     <mailto:rbri@rbri.de>> wrote:
>      >
>      >> Sridhar,
>      >>
>      >> one thing you can do is reusing the client.
>      >> Instead of creating a new client every time, do something like
>      >>
>      >>         WebClient wc = new WebClient(...)
>      >>
>      >>         for ... {
>      >>                 wc.closeAllWindows();
>      >>                 wc.getPage();
>      >>                 ....
>      >>         }
>      >>
>      >> Did a quick test here with google (only loading the page without any
>      >> future processing) and it was a notable difference.
>      >>
>      >>         RBRi
>      >>
>      >>
>      >> On Thu, 8 Aug 2013 02:28:22 +0530 sridhar kura wrote:
>      >> >
>      >> >Hi Team,
>      >> >
>      >> >As per one of your team member suggestion I'm using
>     HTMLUnit2.13 snap shot
>      >> >for submitting a form dynamically to get better performance.
>     But I didn't
>      >> >noticed much difference in the performance.
>      >> >In htmlunit 2.12 domnode.isDisplayed is taking much time but
>     with 2.13
>      >> snap
>      >> >shot DomNode.isDisplayed performance issue has been fixed. But
>     if we
>      >> >compare overall time there is no change. Now with 2.13 java
>     script parsing
>      >> >is taking time.
>      >> >
>      >> >We can't disable javascript and css as our form is dynamic and
>     we hide and
>      >> >show html elements based on the user inputs.
>      >> >
>      >> >So just trying to understand if  HTMLUnit has any caching?
>      >> >If yes what is the scope of the caching?
>      >> >There is a method in WebClient - webclient.getCache()  which gives
>      >> htmlunit
>      >> >cache object.
>      >> >As per the doc it caches css and js. But how can we re-use this
>     object for
>      >> >subsequent requests.
>      >> >
>      >> >e.g If we want to test our client for 100 users.
>      >> >
>      >> >    In my case I'm creating 100 webclient's for every client
>     because in
>      >> the
>      >> >real time the clients will access from 100 different browsers.
>     So trying
>      >> to
>      >> >mimic same behavior.
>      >> >
>      >> >        BrowserVersion bv = BrowserVersion.FIREFOX_17;
>      >> >        this.webClient = new WebClient(bv, env);
>      >> >       -  Creating HTMLPage with the given URL
>      >> >       -  Processing the page
>      >> >       - Submitting the Page.
>      >> >
>      >> >So in the subsequent calls how can I re-use the  objects which
>     are already
>      >> >creating by the htmlunit api in the first request.
>      >> >
>      >> >In the real time we want to test our webapplication for about 1 lac
>      >>  users.
>      >> >But now its taking about 20 hours.
>      >> >We want to achieve this really fast with in few hours(not more
>     than two).
>      >> >
>      >> >Please let me know your thoughts, how can i achieve this.  Let
>     me know if
>      >> >you have any questions
>      >> >
>      >> >
>      >> >
>      >> >Thanks,
>      >> >Sridhar
>      >> >


------------------------------------------------------------------------------
Introducing Performance Central, a new site from SourceForge and 
AppDynamics. Performance Central is your source for news, insights, 
analysis and resources for efficient Application Performance Management. 
Visit us today!
http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
_______________________________________________
Htmlunit-user mailing list
Htmlunit-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/htmlunit-user
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic