Why is the units package so slow?

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?

10898re01.png

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

Why is the units package so slow?

This does not answer my question.

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}

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?

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.