• Post Reply Bookmark Topic Watch Topic
  • New Topic

Tuple class v. array

 
Nick George
Ranch Hand
Posts: 815
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if mass produced, is creating an array of 3 floats faster than creating a Tuple with three floats? How about accessing the floats?

Thanks,
Nick

Is this a bad-to-ask question? I have a fear that whenever I ask this kind of question people just shake their heads and wish I'd crack open a profiler...
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Nick George:
I have a fear that whenever I ask this kind of question people just shake their heads and wish I'd crack open a profiler...


Well, that makes me shake my head and wonder why you don't just do it...

Seriously, I think the answer mostly depends on how you will be using the array/tuple.

I'd probably start using the tuple class, and investigate further once I knew that it isn't fast enough.
 
steve souza
Ranch Hand
Posts: 862
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Is this a bad-to-ask question? I have a fear that whenever I ask this kind of question people just shake their heads and wish I'd crack open a profiler...


Ha, ha - I like that . Most of us are a bit baffled by this type of question as:
1) It is simple enough to create a test and see which is faster
2) usually performance in these micro code situations isn't a factor and you should go with the design that makes more sense (For example if you think you may need 4 elements one day the array might make more sense)

My only concern is that if people quit asking this type of question when I am bored and look for something on java ranch there will be no more questions . Also, I understand many people that ask this type of question are less experienced developers and this may be the place they learn to use a profiler.

Check out the performance faq as a number of these basic P&T concepts are addressed there.

Look at this: http://faq.javaranch.com/view?PerformanceFaq

and in particular this: http://faq.javaranch.com/view?EnterprisePerformance

I have added this link to my signature too.
[ February 04, 2006: Message edited by: steve souza ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!