2
$\begingroup$

The following examples show how slow it is to load a simple GIF. Can anything be done to make it faster?

System #1: Mathematica 8.0.1.0, HP notebook, Win7 64Bit, 2 x 2.4Ghz Intel Core i5, 2GB RAM, w/ integrated Intel graphics chipset

AbsoluteTiming[Import["ExampleData/rose.gif"];]
(* 
  ==> {1.3650781, Null}
*)

System #2: Mathematica 8.0.1.0, MacBook Pro, OSX 10.7.2, 2.4GHz Intel Core i5, 8GB 1333 MHz DDR3 w/ integrated Intel HD graphics 3000 512MB

AbsoluteTiming[Import["ExampleData/rose.gif"];]
(* 
  ==> {2.549696, Null}
*)

Both installations are on local drives.

$\endgroup$
11
  • $\begingroup$ It takes only 0.16 seconds or so (via AbsoluteTiming[]) on my installation (8.0.1 on Xubuntu Oneiric on a generic netbook with an Intel Atom processor); maybe you should mention your OS, Mathematica version, and possibly the specs of your computer? $\endgroup$ Feb 8, 2012 at 13:19
  • 1
    $\begingroup$ Is your Mathematica installed on a local drive or a network drive? File operations can sometimes be a lot slower on networks drives. $\endgroup$ Feb 8, 2012 at 13:37
  • 3
    $\begingroup$ Please use AbsoluteTiming for benchmarking, Timing has surprises.... $\endgroup$
    – user21
    Feb 8, 2012 at 14:06
  • 4
    $\begingroup$ Hmmm. I think this is the case where a great many people can say: "Look, I told you". The performance drop is solely the result of this modified built-in function. $\endgroup$ Feb 8, 2012 at 14:51
  • 3
    $\begingroup$ I suggest to keep this question, in the following format: @Istvan makes his update as an answer. Then, we either close it or as mods to lock it. From that question on StringJoin, we provide a link to here, as a very good case. Because, overloading system functions is an appealing idea to many people, and nothing serves better as a good stand-alone example, like this one. No amount of warnings would be better, since those warnings warn against "theoretical" threats. $\endgroup$ Feb 8, 2012 at 15:42

1 Answer 1

9
$\begingroup$

The cause of the slow speed is the presence of a modified System` function: StringJoin. As this modified StringJoin operates at suboptimal speed (see Leonid's answer and comments here), there is a performance drop of 1-2 magnitudes. So I did learn the hard way why is it a bad idea to modify built-in symbols.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.