473,785 Members | 2,298 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Weird behavoir while using function aliases

I have the following script:

function Test(){}
Test.F = function(){}
Test.F.FF = function(){}
Test.F.FF.FFF = function(){}
Test.F.FF.FFF.F FFF = function(){}

//var alias = function(){};
var alias = Test.F.FF.FFF.F FFF;

var date1 = new Date();
for (var index = 0; index < 100000; index++)
Test.F.FF.FFF.F FFF();
//alias();
var date2 = new Date();
print(date2.get Time() - date1.getTime() );
Why is it when I use Test.F.FF.FFF.F FFF() I get around 100ms and when I
get alias() I get around 280ms?
What is going on here? This is something I would have never anticipated
and I think that neither of you as well. Aliases whould work faster
then doing lockups at each iteration, right?
Also if I uncomment this line: var alias = function(){}, from 280ms I
get a drop to 265 ms?

Does anybody now the reason for this? It only happends in Firefox (I
have 1.5.0.6). IE and Opera behaive as they should

Sep 19 '06
22 2065
VK wrote:
"Alias is more effective then explicit method call" is some
kind of urban legend to me appealing to one of the most
strong mythologems of programming: "shorter text ===
quicker program"; "alias()" is much shorter than
"f.ff.fff.ffff( )", thusly it just has to be more
effective.
Idiot.
With such linear interpretation it would be also obvious
to expect that f() - f.ff.fff.ffff() -
f.ff.fff.ffff.f .ff.fff.ffff() - ...
have to show twice bigger time difference between each
pair from left to right.
You never let English get it the way of your saying nothing worthwile.
In fact the maximum possible performance is very rarely
the primary target in programming. ...
So having realised for yourself that everything you have posted to this
thread to date was utter rubbish you now what to make out that
differences in execution speed don't matter anyway? You would have been
better off staying silent from the outset as then you could avoid looking
such a fool.

Richard.
Sep 24 '06 #21
VK

Richard Cornford wrote:
Idiot.
Halfwit.
With such linear interpretation it would be also obvious
to expect that f() - f.ff.fff.ffff() -
f.ff.fff.ffff.f .ff.fff.ffff() - ...
have to show twice bigger time difference between each
pair from left to right.

You never let English get it the way of your saying nothing worthwile.
I'm sorry if my statement did not fit into your English (neither math)
level. I will try once over step by step:

1) say you have this sequence where each y represents an object
property we want to access and each x some other property we have to
"go throu":
y, x.y, x.x.x.y, x.x.x.x.x.x.x.y , ...

2) in each member of this sequence we have twice longer path to go to
the property y; that is called progression (just in case if you did not
hear this term before). I will not make you all scared by defining what
kind of progression is it (the name starts with "g").

3) With the originally spelled alias idea we must expect that if y has
100ms performance gain over x.y, then x.y over x.x.x.y will give 200ms
gain and so on: we have to expect "twice bigger time difference between
each pair from left to righ".

That is all b.s. at least in application to JScript engine (min.80% of
all users) because its method invocation works on different prociples.
So having realised for yourself that everything you have posted to this
thread to date was utter rubbish you now what to make out that
differences in execution speed don't matter anyway? You would have been
better off staying silent from the outset as then you could avoid looking
such a fool.
Foolish is to discuss internal C++ code mechanics of particular engines
w/o having a clue about this mechanics. That's like writing an esse on
Leo Tolstoy while knowing nothing but that "it's some kind of big
writer".

Sep 24 '06 #22
VK wrote:
Richard Cornford wrote:
>Idiot.

Halfwit.
>>With such linear interpretation it would be also obvious
to expect that f() - f.ff.fff.ffff() -
f.ff.fff.ffff .f.ff.fff.ffff( ) - ...
have to show twice bigger time difference between each
pair from left to right.

You never let English get it the way of your saying nothing
worthwile.

I'm sorry if my statement did not fit into your English
(neither math) level.
It is incoherent.
I will try once over step by step:

1) say you have this sequence where each y represents
an object property we want to access and each x some
other property we have to "go throu":
y, x.y, x.x.x.y, x.x.x.x.x.x.x.y , ...

2) in each member of this sequence we have twice longer
path to go to the property y; that is called progression
(just in case if you did not hear this term before). I
will not make you all scared by defining what kind of
progression is it (the name starts with "g").

3) With the originally spelled alias idea we must expect
that if y has 100ms performance gain over x.y, then x.y
over x.x.x.y will give 200ms gain and so on: we have to
expect "twice bigger time difference between each pair
from left to righ".

That is all b.s. at least in application to JScript engine
(min.80% of all users)
Given that you standards of analysis don't run to distinguishing between
when the code you write works and when it doesn't:-

<URL:
http://groups.google.com/group/comp....20fbcd4b4ab7f8
>
- and you once posted statistics from your own logs that stated that more
of your visitors use Safari than use Mac OS 10 (an impossibility that you
did not notice), I do not place much credence on your declaration of
browser usage. In fact I wouldn't trust you try to addition and get the
answer right.
because its method invocation works on different prociples.
You have just wasted more words saying nothing again. This is a 'straw
man' argument as nobody has ever suggested that the length of a property
accessor would be proportional to the time taken to resolve it. Indeed it
is unlikely that anyone who understands javascript would ever think
anything of the sort as the resolution of a properties on any object may
involve its prototype chain, and so may be influenced by the length of
that chain.

It is not much of an achievement to declare that something that nobody
believes anyway is bullshit.
>So having realised for yourself that everything you have
posted to this thread to date was utter rubbish you now
what to make out that differences in execution speed don't
matter anyway? You would have been better off staying silent
from the outset as then you could avoid looking such a fool.

Foolish is to discuss internal C++ code mechanics of particular
engines w/o having a clue about this mechanics.
<snip>

So why are you doing so? Isn't it more foolish to know that what you are
doing if foolish and then to do it anyway? Indeed isn't it irrational?

Richard.
Sep 25 '06 #23

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

Similar topics

1
1976
by: Jim Dawson | last post by:
I was writing a subroutine to extract fields from lines of text when I ran into an issue. I have reproduced this error on Perl 5.8 on AIX, 5.8 on Linux and 5.6 on Windows. ############### CUT HERE ############### #!/usr/bin/perl -w my @list = ("field1 field2 field3"); sub stripws($)
2
4786
by: Johno | last post by:
I'm using the Dns class to query host names to check that they actually exist on our network and to determine the aliases for each host name. However, I've noticed that the IPHostEntry instance returned by Dns.GetHostByName doesn't return the host name's aliases in the IPHostEntry.Aliases list. But if I pass a host alias to GetHostByName it returns the alias in IPHostEntry.Aliases and the true host name in IPHostEntry.Hostname. It...
2
1441
by: Eyvind W Axelsen | last post by:
Hi. I am creating an application (primarily in C#), with MDI child windows. What I would like to do, is to override the default behavoir that makes a newly createad child form maximized if the topmost childform that already exists is also maximized. Furthermore, if I maximize one form, I don't want all the other forms to be maximized, and the same thing goes for 'restoring' forms to their original size. Any ideas?
24
4753
by: LineVoltageHalogen | last post by:
Greetings All, I was hoping that someone out there has run into this issue before and can shed some light on it for me. I have a stored procedure that essentially does a mini ETL from a source OLTP DB to a the target Operational Data Store. This is still in development so both DB's reside on the same machine for convenience. The stored proc runs successfully from within Query analyzer and this holds true on the following platforms: XP...
0
1641
by: Krzysiek | last post by:
Hi all, I have an issue with QSYS\QADBXREF file - it keeps aliases on tables. I take care of an application that works on many places (servers) and on one of them it's not possible to create alias. I've checked the authority of QADBXREF file on this 'problematic' machine and it's as follows: Object ----------Data--------- --------Object--------- User Group Authority Read Add Upd. Del. Exec. Opr Mgt Exist Alter Ref
15
2453
by: jacob navia | last post by:
Recently, we had a very heated thread about GC with the usual arguments (for, cons, etc) being exchanged. In one of those threads, we came into the realloc problem. What is the realloc problem? Well, it begins with a successfull realloc: char *q = realloc(p,2*n); // for n size_t, a simple
3
2800
by: AAJ | last post by:
Hi all I have the following that looks at a XSD Table adapter JobDescription.VWJobDescriptionMinEducationDataTable m_MinQuals; but for compactness I would like to reference it as Using JobDescription;
1
3185
by: jmalone | last post by:
I have a python script that I need to freeze on AIX 5.1 (customer has AIX and does not want to install Python). The python script is pretty simple (the only things it imports are sys and socket). The README file in the Tools/freeze directory of the Python-2.4.4 distribution says the following (and many other things): Previous versions of Freeze used a pretty simple-minded algorithm to
7
2297
by: Joachim Schmitz | last post by:
Hi folks What would be the expected and correct output of the following #include <stdio.h> int main (void) { char buffer1 = "(10,20,30)"; char buffer2 = "(10,20,30 )"; /* add two white spaces between 30
0
9645
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9481
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10341
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8979
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6741
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5513
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4054
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2881
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.