This link reminded me of this discussion.
http://www.cnn.com/2009/US/07/15/quadrillion.dollar.glitch/index.html?iref=newssearch
as Rich said, unchecked is generally a bad idea. :)
On Wed, Jul 15, 2009 at 10:24 PM, Rich Hickey wrote:
>
>
>
> On Jul 15, 2:22 pm, John Harrop wrote:
>> On Wed, Jul
On Jul 15, 2:22 pm, John Harrop wrote:
> On Wed, Jul 15, 2009 at 11:39 AM, B Smith-Mannschott
> wrote:
>
> > An explicit loop with some type hints is faster, though likely not as
> > fast as Java:
>
> > (defn sum-of-range-4 [range-limit]
> > (loop [i (int 1) s (long 0)]
> > (if (< i range-l
Guys, thanks very much for the fast responses. Of course, this is an
unscientific and totally ad-hock benchmark. I am just *learning*
Clojure and functional programming and I wanted to get some feeling
of how fast Clojure is comparing to java when equivalent idioms are
used . Of course, loop and
On Wed, Jul 15, 2009 at 11:39 AM, B Smith-Mannschott
wrote:
> An explicit loop with some type hints is faster, though likely not as
> fast as Java:
>
> (defn sum-of-range-4 [range-limit]
> (loop [i (int 1) s (long 0)]
>(if (< i range-limit)
> (recur (inc i) (+ s i))
> s)))
>
> This
On Wed, Jul 15, 2009 at 13:51, Dragan wrote:
>
> Hi,
>
> I am trying to compare the performance of java loops to clojure reduce
> function. Noting special, Since I am just learning.
> Java code is something like:
>
> [code]
> long sum = 0;
> for (int i = 1; i < 100; i++ ){
> sum = sum + i;
>
Another note is that these kind of micro-benchmarks are a little difficult
to do correctly in most modern VMs, including Hotspot. In particular, the
kind of tight loop you're doing there where the result isn't used can
sometimes be optimized away by the JIT to go "infinitely" fast. A pretty
good
It's also worth searching this group for 'performance' and checking
out the discussions over the past few months. There've been lots of
queries about many different aspects of performance and some really
good advice dispensed.
- Adrian.
On Wed, Jul 15, 2009 at 3:39 PM, Frantisek Sodomka wrote:
>
PS: Read tips on:
http://clojure.org/java_interop
On Jul 15, 1:51 pm, Dragan wrote:
> Hi,
>
> I am trying to compare the performance of java loops to clojure reduce
> function. Noting special, Since I am just learning.
> Java code is something like:
>
> [code]
> long sum = 0;
> for (int i = 1;
If you make it into a function and use type hints, that should help:
(defn sum [n]
(let [n (int n)]
(loop [ret (long 0) i (int 1)]
(if (< i n)
(recur (+ ret i) (inc i))
ret
user=> (time (reduce + (range 1 100)))
"Elapsed time: 116.959837 msecs"
4950
u
Hi,
On Jul 15, 1:51 pm, Dragan wrote:
> [code]
> long sum = 0;
> for (int i = 1; i < 100; i++ ){
> sum = sum + i;}
>
> [/code]
>
> while in Clojure I used:
>
> [code]
> (reduce + (range 1 i))
> [/code]
Comparing such a loop with reduce is a bit unfair,
since the loop iteration heavily d
Nice code chouser, always nice to see a succinct functional example.
On Dec 13, 10:15 am, Chouser wrote:
> On Sat, Dec 13, 2008 at 10:41 AM, Dmitri wrote:
>
> > I wrote a simple word counter described herehttp://ptrace.fefe.de/wp/
> > it reads stdin and counts the occurrences of words, however
thanks for pointing this out, and I absolutely appreciate the example.
I'm still new to functional approach and I always like to see how
things are done properly.
On Dec 13, 1:15 pm, Chouser wrote:
> On Sat, Dec 13, 2008 at 10:41 AM, Dmitri wrote:
>
> > I wrote a simple word counter described h
To give an example, I tried running through the Iliad from project
gutenberg, it's roughly 1MB of text http://www.gutenberg.org/files/6130/6130.txt
and the program takes ~4600 ms to run, if I comment out printing of
results it runs in ~3700 ms.
By contrast a java version runs in ~560ms.
Now, obv
On Sat, Dec 13, 2008 at 10:41 AM, Dmitri wrote:
>
> I wrote a simple word counter described here http://ptrace.fefe.de/wp/
> it reads stdin and counts the occurrences of words, however I notice
> that it runs significantly slower than the java version in the link.
There are several differences t
I added the time call later on to find what was taking up the cycles,
I also checked the reverse, it's impact is minimal, the print-words
part of the program runs fast, but the read-words takes the majority
of the time.
On Dec 13, 12:38 pm, Jeremy Dunck wrote:
> On Dec 13, 9:41 am, Dmitri wrote
On Dec 13, 9:41 am, Dmitri wrote:
...
> The slowdown seems to occur in the inc-count
> function, where it "updates" the map using the assoc. Is this not a
> proper way to approach this in clojure?
(recur (time (inc-count words head)) tail
You're pretty tightly looping here-- a
On Dec 13, 10:41 am, Dmitri wrote:
> I wrote a simple word counter described herehttp://ptrace.fefe.de/wp/
> it reads stdin and counts the occurrences of words, however I notice
> that it runs significantly slower than the java version in the link.
>
> I was wondering why there is such a dramatic
17 matches
Mail list logo