octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: overloaded functions


From: Paul Kienzle
Subject: Re: overloaded functions
Date: Mon, 13 Jan 2003 22:20:25 -0500
User-agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; en-US; rv:1.2.1) Gecko/20021130

Andy Adler wrote:

[dispatch is] a really useful function, Paul.

Does it add any significant overhead?

A lookup in a very small hash table, an extra feval call, so yes it is
a little bit expensive.

octave:10> tic; for i=1:1000, sin(1); end; toc
ans = 0.047647
octave:11> tic; for i=1:1000, cos(1); end; toc
ans = 0.037207

If you wanted to, you could keep the actual function values in the
structure, and so avoid the extra feval.  Since the number of types
we are likely to dispatch against is small, an array is perhaps a
better representation then a map.  You could be using type-ids rather
than strings to compare types.  This might be enough to make the
presense of dispatch unmeasurable.

Paul Kienzle
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]