On Tue, 2009-09-29 at 09:08 -0700, Matt wrote:

> So, using mytime2 with the myavgtime macro gives average execution
> times for the expression (+ 1 2 3) of 2 to 3 times longer than when
> using mytime1. Why is this? Does the JIT optimize differently with all
> those println's when using mytime2? (Kind of "quantum mechanics-y" -
> observing what's going on changes it.)

Output is painstakingly slow in all languages I've ever dealt with (I
first noticed it in C).   Most of the time it isn't noticed because
there's a lot of other non-trivial stuff going on.

Here's a comparison of a tight loop in C that does a printf vs one that
doesn't (1,000,000 iterations of a simple calculation):

With printf:
real    0m23.534s
user    0m0.396s
sys     0m3.232s

Without printf:
real    0m0.018s
user    0m0.012s
sys     0m0.000s

and for comparison, the same in Python:

With print:
real    0m25.879s
user    0m2.172s
sys     0m3.300s

Without print:
real    0m0.596s
user    0m0.532s
sys     0m0.052s

Notice that with console output, the Python program is almost as fast (or as 
slow) as
the C version =) 

In short, you've taken something that was originally CPU-bound and made it 
I/O-bound.

Regards,
Cliff



--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to