I was trying to make an application go faster today when I found out that a Java program that does pretty much the same task was 8 times faster. I used the -Xrunhprof:cpu=times profiling flag to know where I should look, and the results are a little puzzling:
CPU TIME (ms) BEGIN (total = 3334005) Mon Mar 16 15:26:26 2009 rank self accum count trace method 1 33.09% 33.09% 6 302294 java.lang.ref.ReferenceQueue.remove 2 33.09% 66.17% 3 302283 java.lang.Object.wait 3 1.11% 67.28% 4681282 304233 java.util.concurrent.atomic.AtomicInteger.get 4 1.05% 68.34% 1273366 326814 clojure.lang.Var.deref 5 0.82% 69.15% 162675 326831 starcraft.replay.parse $parse_buffer__65$fn__68.invoke 6 0.75% 69.90% 162710 326175 clojure.lang.APersistentVector.doEquals 7 0.67% 70.58% 1273672 325764 clojure.lang.Var.getThreadBinding 8 0.67% 71.24% 1273366 326815 clojure.lang.Var.get 9 0.54% 71.79% 650700 326818 clojure.core$nth__3505.invoke 10 0.50% 72.29% 650700 326817 clojure.lang.RT.nth 11 0.38% 72.67% 462044 326102 clojure.lang.Var.deref 12 0.37% 73.04% 162718 325793 clojure.lang.APersistentVector.hashCode 13 0.37% 73.40% 153954 326133 starcraft.replay.parse $read_field_aux__32.invoke 14 0.35% 73.75% 659541 312088 clojure.lang.Var.getThreadBinding 15 0.34% 74.09% 650840 326173 clojure.lang.APersistentVector $2.next 16 0.32% 74.41% 385545 312090 clojure.lang.Var.deref 17 0.30% 74.71% 1273672 325765 clojure.lang.Var.hasRoot 18 0.30% 75.01% 19608 327262 starcraft.replay.unpack $decode_command_block__93.invoke 19 0.27% 75.28% 517194 326100 clojure.lang.Var.getThreadBinding 20 0.26% 75.54% 488130 326171 clojure.lang.APersistentVector $2.hasNext Can anyone explain how 9 method calls can be responsible for 66% of my runtime and how I could avoid this overhead? The AtomicInteger.get also intrigues me. My code is available at the following address if you need to see it: http://bitbucket.org/gnuvince/clj-starcraft/src/ Thank you, Vincent. --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---