I can get more consistent results when running the examples in Ubuntu. On Monday, November 5, 2012 6:09:25 AM UTC+8, Marek Šrank wrote: > > These are my results using (dotimes (time (dotimes ...))) combo to get > consistent results: > > - on sets: > > (dotimes [i 10] (time (dotimes [j 100] (into #{} (range 1e4))))) > "Elapsed time: 388.595226 msecs" > "Elapsed time: 406.666801 msecs" > "Elapsed time: 421.559753 msecs" > "Elapsed time: 444.719263 msecs" > "Elapsed time: 431.319374 msecs" > "Elapsed time: 392.3779 msecs" > "Elapsed time: 392.382365 msecs" > "Elapsed time: 408.71734 msecs" > "Elapsed time: 444.203973 msecs" > "Elapsed time: 442.351363 msecs" > > (dotimes [i 10] (time (dotimes [j 100] (naive-into #{} (range 1e4))))) > "Elapsed time: 1287.412806 msecs" > "Elapsed time: 1318.931199 msecs" > "Elapsed time: 1314.773064 msecs" > "Elapsed time: 1292.664029 msecs" > "Elapsed time: 1277.616099 msecs" > "Elapsed time: 1289.514678 msecs" > "Elapsed time: 1700.74875 msecs" > "Elapsed time: 1352.734662 msecs" > "Elapsed time: 1464.09882 msecs" > "Elapsed time: 1449.704738 msecs" > > - on vectors: > > (dotimes [i 10] (time (dotimes [j 100] (into [] (range 1e4))))) > "Elapsed time: 307.838501 msecs" > "Elapsed time: 243.426624 msecs" > "Elapsed time: 234.013566 msecs" > "Elapsed time: 247.711805 msecs" > "Elapsed time: 253.154264 msecs" > "Elapsed time: 284.375476 msecs" > "Elapsed time: 227.773865 msecs" > "Elapsed time: 247.807286 msecs" > "Elapsed time: 240.959477 msecs" > "Elapsed time: 230.627513 msecs" > > (dotimes [i 10] (time (dotimes [j 100] (naive-into [] (range 1e4))))) > "Elapsed time: 406.55752 msecs" > "Elapsed time: 419.365134 msecs" > "Elapsed time: 413.544069 msecs" > "Elapsed time: 410.892756 msecs" > "Elapsed time: 394.827165 msecs" > "Elapsed time: 407.338251 msecs" > "Elapsed time: 441.60916 msecs" > "Elapsed time: 401.721826 msecs" > "Elapsed time: 412.7506 msecs" > "Elapsed time: 399.972445 msecs" > > > Clojure 1.4.0 > > java version "1.6.0_26" > Java(TM) SE Runtime Environment (build 1.6.0_26-b03) > Java HotSpot(TM) Server VM (build 20.1-b02, mixed mode) > > > Cheers. > > Marek. > > On Sunday, November 4, 2012 3:41:14 AM UTC+1, Satoru Logic wrote: >> >> Hi, all. >> >> I am following an example demonstrating that `transient` can help >> optimize mass updates to data structures: >> >> First, a function is defined, which doesn't use transient collection: >> >> (defn naive-into >>> [coll source] >>> (reduce conj coll source)) >> >> >> This is supposed to run slower than the built-in `into`, because, as the >> book said, `into` uses transient collections whenever possible. >> >> But the result shows up in my `repl` is just the reverse. >> >> >>> user=> (time (do (into #{} (range 1e6)) nil)) >>> "Elapsed time: 4882.176 msecs" >>> nil >>> user=> (time (do (naive-into #{} (range 1e6)) nil)) >>> "Elapsed time: 3745.707 msecs" >>> nil >> >> >> What could be the reason of this? >> >
-- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en