473,397 Members | 1,950 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Browser/JavaScript caching "code execution?" (For lack of betterterminology.)

I have been watching code execution in various situations and I have
noticed something.

On the first test my example gave me obvious results. One method was
far faster than the other. However, upon executing the code again
(without refreshing the browser) the two tests were almost identical in
speed.

I am not sure if this has something to do specifically with JavaScript
(and/or its engine) or if this is just something browsers try to implement.

What type of "code execution caching" am I seeing?

--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
Jun 7 '07 #1
2 1973
-Lost wrote:
I have been watching code execution in various situations
and I have noticed something.

On the first test my example gave me obvious results.
One method was far faster than the other. However, upon
executing the code again (without refreshing the browser)
the two tests were almost identical in speed.

I am not sure if this has something to do specifically
with JavaScript (and/or its engine) or if this is just
something browsers try to implement.

What type of "code execution caching" am I seeing?
Popular browsers have decent javascript engines that work pretty well
in most situations, but this kind of observations may occur. IMHO the
first thing to do is to make sure that the javascript code itself does
not have any (hidden) memory leaks. This isn't as obvious as it may
sound; especially in complex architectures.

This is actually the most you can do. Once the code is passed to the
engine for execution, all you can do is pray that it's a decent
engine. You can't control the mechanisms that are used there.

Regarding your test case, it looks like the memory isn't flushed. The
browser's javascript engine must have a (un)justified reason why it
keeps it in memory. AFAIK there is only one (JScript) command to clear
up such "garbage", but you will not want to use it:

CollectGarbage()

See:
http://groups.google.com/group/comp....3c7c11f20ad185

I've done javascript memory benchmarks some time ago comparing
Microsoft Internet Explorer and Firefox memory performance. These
indicated that Firefox generally has a much stronger allocation
model.

--
Bart

Jun 9 '07 #2
Bart Van der Donck wrote:
-Lost wrote:
>I have been watching code execution in various situations
and I have noticed something.

On the first test my example gave me obvious results.
One method was far faster than the other. However, upon
executing the code again (without refreshing the browser)
the two tests were almost identical in speed.

I am not sure if this has something to do specifically
with JavaScript (and/or its engine) or if this is just
something browsers try to implement.

What type of "code execution caching" am I seeing?

Popular browsers have decent javascript engines that work pretty well
in most situations, but this kind of observations may occur. IMHO the
first thing to do is to make sure that the javascript code itself does
not have any (hidden) memory leaks. This isn't as obvious as it may
sound; especially in complex architectures.

This is actually the most you can do. Once the code is passed to the
engine for execution, all you can do is pray that it's a decent
engine. You can't control the mechanisms that are used there.

Regarding your test case, it looks like the memory isn't flushed. The
browser's javascript engine must have a (un)justified reason why it
keeps it in memory. AFAIK there is only one (JScript) command to clear
up such "garbage", but you will not want to use it:

CollectGarbage()

See:
http://groups.google.com/group/comp....3c7c11f20ad185

I've done javascript memory benchmarks some time ago comparing
Microsoft Internet Explorer and Firefox memory performance. These
indicated that Firefox generally has a much stronger allocation
model.
Thanks for the information!

--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
Jun 11 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Yvan J. Gagnon | last post by:
I am currenly developing a web site using Macromedia fireworks, and am trying to figure out a way (through hand-coding) of attaching a javascript function (onClick="doit=false") to each of the...
9
by: Marcus Sheen [UK] | last post by:
Have done searches for similar questions, but cannot find anything. Nor can I find any resources via Google (Javascript Source etc). Thinking about implementing a topical "On This Day" feature on...
53
by: Cardman | last post by:
Greetings, I am trying to solve a problem that has been inflicting my self created Order Forms for a long time, where the problem is that as I cannot reproduce this error myself, then it is...
2
by: Amir | last post by:
What the for="window" is used for in the <script> tag? TIA
12
by: Ken Varn | last post by:
Is there anyway within my web application that I can have all browser caching turned off for all aspx pages sent by my IIS server? I need to have all caching off in order for certain things to...
28
by: Noone Here | last post by:
AIUI, it was not all that long ago when the threat to personal users, was attachments that when executed compromised machines with keyloggers, trojans, etc. Now it seems that the big problem is...
2
by: Water Cooler v2 | last post by:
http://www.w3schools.com/js/js_whereto.asp This link is to a JavaScript tutorial on w3schools. The page says that a script put in the HEAD is executed only when called, whereas one put in the...
4
by: Ralphz | last post by:
Hi How do I stop JavaScript execution when I encounter an error? Is there something similar to PHP's exit or die function? Thanks Ralph
5
by: mesut | last post by:
Hi there, how are you colleagues? I try to set a linkaddress in code behind for a <asp:hyperlinkserver control. but I think I have some syntax problem. I don't know how to fix it. What's...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.