Thanks, that does look nice. If I end up wanting to do any image manipulation I
will definitely check it out. For now, all I need to do is be able to create a
graphics context into which I can draw the user interface, then convert it into
bits in the proper format, and blast them over USB to the
I have a useful library for image manipulation in Clojure, you may find it
useful:
https://github.com/mikera/imagez
New ideas / PRs gratefully received!
On Sunday, 13 March 2016 04:14:34 UTC+8, James Elliott wrote:
>
> Interesting! This is the first time I have had to drop out of Clojure for
>
Interesting! This is the first time I have had to drop out of Clojure for
performance reasons. It is not too surprising, given that I am doing
low-level byte bashing in a tight loop to send pixels to a display over USB
at sixty frames per second. But it is surprising that nothing like this has
Consider using criterium or similar for benchmarking. (time) is ok for rough
and ready, but by the time you've navigated the tiered JIT of the JVM it just
isn't good enough to be able to make useful inferences from the results.
Pete
--
You received this message because you are subscribed to th
I've only skimmed this thread quickly, so if I am repeating the obvious
just ignore me :-)
I haven't noticed anyone suggesting parallelising your problem.
Take the best sequential solution that you have found, divide the size of
the array by the number of cores that you have available, then ha
Ok so,
This is what i got of running @Lein code example using hiphip 4 times in a
row,
performance is now acceptable add I'm happy about it
"Elapsed time: 9.096 msecs"
"Elapsed time: 1.707 msecs"
"Elapsed time: 1.493 msecs"
"Elapsed time: 0.839 msecs"
Turning :aot on didn't fix the first outlier
This is a lot messier than I thought it would be.
So far the fastest code is from @Michael_Gardner with the dotimes (~100ms)
Once I add :jvm-opts ^:replace [] on my profile and (set! *unchecked-math*
true) several examples drop to ~80ms
but @Leif example using hiphip drops to ~30ms.
@Leif I ca
My best guess would be that I've used the loop version in places where I
had (set! *unchecked-math* true) - I see that dotimes uses unchecked-inc so
that might explain it. See what happens with this version.
(defn inplace-xor [^bytes a ^bytes b ^bytes out]
(let [len (alength a)]
(loop [i
Based on what Jozef said, I could write
(defn inplace-xor-hh [^bytes a ^bytes b ^bytes out]
(hiphip.array/afill! Byte/TYPE [_ out x a y b] (bit-xor (long x) (long
y
It took 2 ms on my machine, vs. 80 ms for the 'dotimes' solution.' I think
that matches java's speed, but if not, I'm guess
Note that looping with primitive int is faster than with long, and native
array functions accepts/returns int instead of long for their index and
length.
It is very hard to eliminate boxing without dropping to java. In you
example, calling bit-xor does 2 autoboxing (and 1 long to int cast as
aset-
On Mar 13, 2014, at 07:34 , Alex Miller wrote:
> Agreed with all the comments on this so far. I would also say that dotimes is
> slower than loop for stuff like this so I would also make that change.
The dotimes version is slightly faster on my hardware. Why would it be slower?
--
You receive
Agreed with all the comments on this so far. I would also say that dotimes
is slower than loop for stuff like this so I would also make that change.
(defn inplace-xor [^bytes a ^bytes b ^bytes out]
(let [len (alength a)]
(loop [i 0]
(when (< i len)
(aset-byte out i (bit-xor (
Hi, Ignacio.
Performance tuning in clojure being somewhat complicated, I would look for
prior art here. For instance, the suggestions above give me a 6x speedup,
but it's still *way* slower than the equivalent java code. So I used
Prismatic's hiphip (array)! library on your problem (but with
Might be slow because of the polymorphic nature of nth. If you replace nth with
aget (and turn on *warn-on-reflection*, which is a good idea when
performance-tuning), you'll get reflection warnings because Clojure doesn't
know what Java method to use since it doesn't know what type of objects a
Try this:
(defn inplace-xor [^bytes a ^bytes b ^bytes out]
(let [ln (count a)]
(loop [x 0]
(if (< x ln)
(do
(aset-byte out x (bit-xor (aget a x) (aget b x)))
(recur (inc x)))
On Thursday, March 13, 2014 6:26:33 AM UTC+1, Ignacio Corderi wrote:
>
> Hey g
15 matches
Mail list logo