Compile JS on page load

View: New views
5 Messages — Rating Filter:   Alert me  

Compile JS on page load

by Adim :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,
I was wondering does each getPage call or other JS related actions cause the javascript engine to compile the code all over again? Is there any cache?
I want to figure out how I can improve HTMLUnit performance beside the offered things (such as disable CSS, filter JS on connection time).

Regards,
Adi.

Re: Compile JS on page load

by Marc Guillemot :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Adi,

HtmlUnit doesn't compile JS: it uses Rhino's interpreted mode, meaning
that JS is just parsed to build an AST which is a bit optimized to be
interpreted but not Java bytecode is generated.
We already try to cache what can be cached to be avoid parsing again
when it is not needed.

If you want to improve performance, have you done some profiling to see
where the time is lost?

Cheers,
Marc.
--
Web: http://www.efficient-webtesting.com
Blog: http://mguillem.wordpress.com

Adim wrote:
> Hi,
> I was wondering does each getPage call or other JS related actions cause the
> javascript engine to compile the code all over again? Is there any cache?
> I want to figure out how I can improve HTMLUnit performance beside the
> offered things (such as disable CSS, filter JS on connection time).
>
> Regards,
> Adi.


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Htmlunit-user mailing list
Htmlunit-user@...
https://lists.sourceforge.net/lists/listinfo/htmlunit-user

Re: Compile JS on page load

by Adim :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Marc,
I know that the Rhino does not actually compile the source but it parsers the code and generate a Script object, is there any cache involve?
Regarding performence I allready run some profiling and the most consuming time is taken by the getPage (I connect to relay heavy website with massive javascript support - I already filter the non need ones but still it slows).

Adi.


Marc Guillemot wrote:
Hi Adi,

HtmlUnit doesn't compile JS: it uses Rhino's interpreted mode, meaning
that JS is just parsed to build an AST which is a bit optimized to be
interpreted but not Java bytecode is generated.
We already try to cache what can be cached to be avoid parsing again
when it is not needed.

If you want to improve performance, have you done some profiling to see
where the time is lost?

Cheers,
Marc.
--
Web: http://www.efficient-webtesting.com
Blog: http://mguillem.wordpress.com

Adim wrote:
> Hi,
> I was wondering does each getPage call or other JS related actions cause the
> javascript engine to compile the code all over again? Is there any cache?
> I want to figure out how I can improve HTMLUnit performance beside the
> offered things (such as disable CSS, filter JS on connection time).
>
> Regards,
> Adi.


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Htmlunit-user mailing list
Htmlunit-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/htmlunit-user

Re: Compile JS on page load

by Marc Guillemot :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

sure that getPage takes most of the time: it has to do all HTTP
requests. Besides these requests, can you identify some excessive time
consuming calls?

Yes, Rhino Script object are cached, when possible.

Cheers,
Marc.
--
Web: http://www.efficient-webtesting.com
Blog: http://mguillem.wordpress.com

Adim wrote:

> Hi Marc,
> I know that the Rhino does not actually compile the source but it parsers
> the code and generate a Script object, is there any cache involve?
> Regarding performence I allready run some profiling and the most consuming
> time is taken by the getPage (I connect to relay heavy website with massive
> javascript support - I already filter the non need ones but still it slows).
>
> Adi.
>
>
>
> Marc Guillemot wrote:
>> Hi Adi,
>>
>> HtmlUnit doesn't compile JS: it uses Rhino's interpreted mode, meaning
>> that JS is just parsed to build an AST which is a bit optimized to be
>> interpreted but not Java bytecode is generated.
>> We already try to cache what can be cached to be avoid parsing again
>> when it is not needed.
>>
>> If you want to improve performance, have you done some profiling to see
>> where the time is lost?
>>
>> Cheers,
>> Marc.
>> --
>> Web: http://www.efficient-webtesting.com
>> Blog: http://mguillem.wordpress.com
>>
>> Adim wrote:
>>> Hi,
>>> I was wondering does each getPage call or other JS related actions cause
>>> the
>>> javascript engine to compile the code all over again? Is there any cache?
>>> I want to figure out how I can improve HTMLUnit performance beside the
>>> offered things (such as disable CSS, filter JS on connection time).
>>>
>>> Regards,
>>> Adi.
>>
>> ------------------------------------------------------------------------------
>> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
>> is the only developer event you need to attend this year. Jumpstart your
>> developing skills, take BlackBerry mobile applications to market and stay
>> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
>> http://p.sf.net/sfu/devconference
>> _______________________________________________
>> Htmlunit-user mailing list
>> Htmlunit-user@...
>> https://lists.sourceforge.net/lists/listinfo/htmlunit-user
>>
>>
>


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Htmlunit-user mailing list
Htmlunit-user@...
https://lists.sourceforge.net/lists/listinfo/htmlunit-user

Re: Compile JS on page load

by gredler :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

http://htmlunit.sourceforge.net/apidocs/com/gargoylesoftware/htmlunit/WebClient.html#getCache%28%29

http://htmlunit.sourceforge.net/apidocs/com/gargoylesoftware/htmlunit/Cache.html


On Tue, Oct 27, 2009 at 8:53 AM, Marc Guillemot <mguillemot@...> wrote:
Hi,

sure that getPage takes most of the time: it has to do all HTTP
requests. Besides these requests, can you identify some excessive time
consuming calls?

Yes, Rhino Script object are cached, when possible.

Cheers,
Marc.
--
Web: http://www.efficient-webtesting.com
Blog: http://mguillem.wordpress.com

Adim wrote:
> Hi Marc,
> I know that the Rhino does not actually compile the source but it parsers
> the code and generate a Script object, is there any cache involve?
> Regarding performence I allready run some profiling and the most consuming
> time is taken by the getPage (I connect to relay heavy website with massive
> javascript support - I already filter the non need ones but still it slows).
>
> Adi.
>
>
>
> Marc Guillemot wrote:
>> Hi Adi,
>>
>> HtmlUnit doesn't compile JS: it uses Rhino's interpreted mode, meaning
>> that JS is just parsed to build an AST which is a bit optimized to be
>> interpreted but not Java bytecode is generated.
>> We already try to cache what can be cached to be avoid parsing again
>> when it is not needed.
>>
>> If you want to improve performance, have you done some profiling to see
>> where the time is lost?
>>
>> Cheers,
>> Marc.
>> --
>> Web: http://www.efficient-webtesting.com
>> Blog: http://mguillem.wordpress.com
>>
>> Adim wrote:
>>> Hi,
>>> I was wondering does each getPage call or other JS related actions cause
>>> the
>>> javascript engine to compile the code all over again? Is there any cache?
>>> I want to figure out how I can improve HTMLUnit performance beside the
>>> offered things (such as disable CSS, filter JS on connection time).
>>>
>>> Regards,
>>> Adi.
>>
>> ------------------------------------------------------------------------------
>> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
>> is the only developer event you need to attend this year. Jumpstart your
>> developing skills, take BlackBerry mobile applications to market and stay
>> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
>> http://p.sf.net/sfu/devconference
>> _______________________________________________
>> Htmlunit-user mailing list
>> Htmlunit-user@...
>> https://lists.sourceforge.net/lists/listinfo/htmlunit-user
>>
>>
>


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Htmlunit-user mailing list
Htmlunit-user@...
https://lists.sourceforge.net/lists/listinfo/htmlunit-user



--
Daniel Gredler
http://daniel.gredler.net/

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Htmlunit-user mailing list
Htmlunit-user@...
https://lists.sourceforge.net/lists/listinfo/htmlunit-user