2

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.

István Zachar
  • 47,032
  • 20
  • 143
  • 291
  • 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? – J. M.'s missing motivation Feb 08 '12 at 13:19
  • 1
    Is your Mathematica installed on a local drive or a network drive? File operations can sometimes be a lot slower on networks drives. – Arnoud Buzing Feb 08 '12 at 13:37
  • 3
    Please use AbsoluteTiming for benchmarking, Timing has surprises.... –  Feb 08 '12 at 14:06
  • on OS X 10.7 and mma 8.0.1, this takes 0.2s seconds. This is with an SSD, though. – acl Feb 08 '12 at 14:29
  • On my macbook with OS X 10.7 and Mathematica 8.0.4 it takes .4 seconds. – Heike Feb 08 '12 at 14:50
  • 4
    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. – István Zachar Feb 08 '12 at 14:51
  • Should I remove this question, as it is extremely specific (i.e. it applies only to my system)? – István Zachar Feb 08 '12 at 14:59
  • In a fresh kernel, Table[AbsoluteTiming[Import["ExampleData/rose.gif"];], {10}] gives {0.3580204, 0.0920053, 0.0880050, 0.0790046, 0.0680039, 0.0690039, 0.0700040, 0.0920053, 0.0800045, 0.0610035}. v8.0.4, Windows. – Szabolcs Feb 08 '12 at 15:04
  • 3
    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. – Leonid Shifrin Feb 08 '12 at 15:42
  • I think it makes sense to leave it, as a nice example of what can go wrong with overloading built-in functions. – acl Feb 08 '12 at 16:01
  • "Then, we either close it" - I've cast a "too localized" close vote, as there doesn't seem to be a more appropriate closure reason... – J. M.'s missing motivation Feb 08 '12 at 16:06

1 Answers1

9

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.

István Zachar
  • 47,032
  • 20
  • 143
  • 291