Message Boards Message Boards

0
|
10022 Views
|
7 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Why is the units package so slow?

Posted 10 years ago

Say that I have the two following lines of code:

AbsoluteTiming[Table[Quantity[i, "Seconds"]/Quantity[1, "Seconds"], {i, 60}];]

AbsoluteTiming[Table[i/1, {i, 60}];]

The first takes almost 3 seconds to evaluate, whereas the second takes under 1/100th of a second. Other than not using units whatsoever, is there any way to speed up computation with units? And is the Mathematica team looking into making the units package any faster?

POSTED BY: anand
7 Replies
Posted 10 years ago

It is slower but not nearly as slow as you suggest, I had to run 6000 (not 60) to get numbers to compare.

In[112]:= AbsoluteTiming[ Table[Quantity[i, "Seconds"]/Quantity[1, "Seconds"], {i, 6000}];]

AbsoluteTiming[Table[i/1, {i, 6000}];]

Out[112]= {0.0190010, Null}

Out[113]= {0.0010000, Null}

POSTED BY: Elton TeKolste
Posted 10 years ago

I tried your code but it took over 20 seconds so I aborted. I'm running Mathematica 10.0.2.0 (Student version) on Mac OSX. Are you using a different version?

POSTED BY: anand
Posted 10 years ago

Interesting. I am running Mathematica 8.0.4.0 on a PC (with an I7 quad core CPU) running Windows 7.

A number of possibilities come to mind, but I would start with by using the Task Manager to check what you have running on your machine.

POSTED BY: Elton TeKolste

Why is the units package so slow?

POSTED BY: Simon Cadrin
Posted 10 years ago

This does not answer my question.

POSTED BY: anand
Posted 10 years ago

I don't believe there is a division by 0 in either code. What does this comment mean?

POSTED BY: anand

enter image description here

POSTED BY: Simon Cadrin
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract