If 2 were slow pretty much all of Julia would be super slow ;-)

Do let us know how it goes.


On Sat, Aug 9, 2014 at 10:32 PM, Chris Binz <[email protected]> wrote:

> Thanks, Kevin and Stefan. I was hoping 2 was the right way, but worried
> that it might negate some of the advantage of using multiple dispatch in
> the first place. In any case, if/when I get some performance numbers, I'll
> try to remember to update this with them.
>
> Chris
>
>
> On Saturday, August 9, 2014 10:23:33 PM UTC-4, Stefan Karpinski wrote:
>
>> 2 is the way to go – it's very likely that there is zero overhead due to
>> inlining.
>>
>>
>> On Sat, Aug 9, 2014 at 6:36 PM, Kevin Squire <[email protected]> wrote:
>>
>>> Hi Chris,
>>>
>>> On Sat, Aug 9, 2014 at 3:30 PM, Chris Binz <[email protected]> wrote:
>>>
>>>> Say I have a function that performs one calculation, but for different
>>>> argument types. For instance, I have a satellite orbit propagator that
>>>> returns the satellite state at some time, given the initial state and the
>>>> desired time. I would like to specify the desired time either as an elapsed
>>>> number of seconds OR, say, a DateTime object. The calculation itself is
>>>> largely the same, and requires elapsed seconds. What is the best way to
>>>> write this?
>>>>
>>>> I suppose my options are:
>>>>
>>>>    1. Multiple dispatch - two methods, with essentially duplicate code
>>>>    (seems undesirable to me).
>>>>    2. Multiple dispatch - two methods, but the method that takes
>>>>    DateTime as input simply converts to seconds and then calls the other
>>>>    method. Is there a performance hit for this?
>>>>    3. One method, where the type of the desired time is checked and
>>>>    converted up front if necessary.
>>>>    4. Other (?)
>>>>
>>>> Your number 2 type is probably the best solution.  How much of a
>>> performance hit depends entirely on how long the different parts of the
>>> calculation take, so you'll have to test that and tell us. :-)
>>>
>>> Cheers,
>>>    Kevin
>>>
>>
>>

Reply via email to