Re: transient/persistent! not worth for less than 7-8 operations

2012-11-09 Thread Cedric Greevey
N could equal 1 under circumstances that make T small enough or d large
enough. T might be small for a tiny collection, or d large for a large
collection. Access pattern might matter, too. If a particular sequence of
inserts causes a lot of worst-case tree rotations or something, say, maybe
it could make the next insert particularly expensive to perform, but only
for a persistent collection. I'd have to dig into the actual implementation
to be more certain.

I'd expect that N will be greater than 1 for all but fairly atypical
circumstances, though, which fits with a few observations of transients
being faster for a tiny number of operations and many observations of
transients not being faster for a tiny number of operations.



On Fri, Nov 9, 2012 at 10:12 AM, Jim foo.bar  wrote:

> exactly the point I was trying to make! However, other peoples' experiment
> seem not to agree with that!
>
> Jim
>
>
>
> On 09/11/12 15:09, Cedric Greevey wrote:
>
>> In the real world, it's more complicated than that, and N could end up
>> not only depending on which transient operations and on vector vs. map but
>> even on details of the system hardware, Clojure version, and JVM version.
>> However it's likely to be a small integer in every case, so if you're doing
>> dozens or hundreds or more of operations, transients will generally help,
>> and if you're only doing one or two, don't bother.
>>
>
> --
> 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+unsubscribe@**googlegroups.com
> For more options, visit this group at
> http://groups.google.com/**group/clojure?hl=en
>

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

Re: transient/persistent! not worth for less than 7-8 operations

2012-11-09 Thread Jim foo.bar
exactly the point I was trying to make! However, other peoples' 
experiment seem not to agree with that!


Jim


On 09/11/12 15:09, Cedric Greevey wrote:
In the real world, it's more complicated than that, and N could end up 
not only depending on which transient operations and on vector vs. map 
but even on details of the system hardware, Clojure version, and JVM 
version. However it's likely to be a small integer in every case, so 
if you're doing dozens or hundreds or more of operations, transients 
will generally help, and if you're only doing one or two, don't bother.


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


Re: transient/persistent! not worth for less than 7-8 operations

2012-11-09 Thread Cedric Greevey
It stands to reason that transients won't help given a small number of
operations. Consider a simplified model where conversion to transient and,
eventually, back to persistent takes a constant number of cycles T and
every operation on a transient takes exactly d cycles less than the
corresponding operation on a persistent. The savings from using transients
is then nd - T for n operations between making transient and making
persistent again. If d is much smaller than T then nd will be less than T
for the first several n, and using transients will be slower for n less
than some threshold N. (N = ceil(T/d) in fact.)

In the real world, it's more complicated than that, and N could end up not
only depending on which transient operations and on vector vs. map but even
on details of the system hardware, Clojure version, and JVM version.
However it's likely to be a small integer in every case, so if you're doing
dozens or hundreds or more of operations, transients will generally help,
and if you're only doing one or two, don't bother.


On Fri, Nov 9, 2012 at 7:27 AM, Softaddicts wrote:

> Ubuntu 12.04, java 6 32 bits
>
> Luc P.
>
>
> > This is weird...for just 2 operations I'm getting consistently better
> > timings with persistent than transients...
> >
> > user=> (time (dotimes [_ 100] (assoc [1 2 3 4 5 6 7 8 9 0] 3 5 6 8)))
> > "Elapsed time: 240.247405 msecs"
> > nil
> > user=>
> > user=> (time (dotimes [_ 100] (persistent! (assoc! (transient [1 2 3
> > 4 5 6 7 8 9 0]) 3 5 6 8
> > "Elapsed time: 354.122806 msecs"
> > nil
> > user=> (time (dotimes [_ 100] (assoc [1 2 3 4 5 6 7 8 9 0] 3 5 6 8)))
> > "Elapsed time: 188.765493 msecs"
> > nil
> > user=> (time (dotimes [_ 100] (persistent! (assoc! (transient [1 2 3
> > 4 5 6 7 8 9 0]) 3 5 6 8
> > "Elapsed time: 318.90242 msecs"
> > nil
> >
> > Jim
> >
> > ps: are you guys on java 1.7 ?
> >
> > On 09/11/12 02:29, Softaddicts wrote:
> > > Roughly... My FPU module is slow tonight
> > >
> > >
> > >> My own tests shows that the transient version is twice as fast:
> > >>
> > >> (time (dotimes [_ 100] (assoc [1 2 3 4 5 6 7 8 9 0] 3 5 6 8)))
> > >> Elapsed time: 711.848312 msecs
> > >>
> > >> (time (dotimes [_ 100] (persistent! (assoc! (transient [1 2 3 4 5
> 6 7 8 9 0]) 3 5 6 8
> > >> Elapsed time: 399.466556 msecs
> > >>
> > >> Luc P.
> > >>
> > >>> user=>  (use '[criterium.core])
> > >>> nil
> > >>> user=> (bench (assoc [1 2 3 4 5 6 7 8 9 0] 3 nil 6 'a)) ;;2
> operations
> > >>>
> > >>> Evaluation count : 125829120 in 60 samples of 2097152 calls.
> > >>>Execution time mean : 488.826554 ns
> > >>>   Execution time std-deviation : 19.952095 ns
> > >>>  Execution time lower quantile : 459.910320 ns ( 2.5%)
> > >>>  Execution time upper quantile : 527.008269 ns (97.5%)
> > >>> nil
> > >>> user=> (bench (persistent! (assoc! (transient [1 2 3 4 5 6 7 8 9 0])
> 3
> > >>> nil 6 'a)))
> > >>> Evaluation count : 97399860 in 60 samples of 1623331 calls.
> > >>>Execution time mean : 639.789263 ns
> > >>>   Execution time std-deviation : 26.265080 ns
> > >>>  Execution time lower quantile : 597.753127 ns ( 2.5%)
> > >>>  Execution time upper quantile : 687.838668 ns (97.5%)
> > >>> nil
> > >>> user=> (bench (assoc [1 2 3 4 5 6 7 8 9 0] 3 nil 6 'a 0 "z" 2 5)) ;;4
> > >>> operations
> > >>> Evaluation count : 68275920 in 60 samples of 1137932 calls.
> > >>>Execution time mean : 901.407416 ns
> > >>>   Execution time std-deviation : 35.682637 ns
> > >>>  Execution time lower quantile : 851.060950 ns ( 2.5%)
> > >>>  Execution time upper quantile : 970.492949 ns (97.5%)
> > >>>
> > >>> Found 1 outliers in 60 samples (1.6667 %)
> > >>>   low-severe 1 (1.6667 %)
> > >>>Variance from outliers : 25.4849 % Variance is moderately
> inflated by
> > >>> outliers
> > >>> nil
> > >>> user=> (bench (persistent! (assoc! (transient [1 2 3 4 5 6 7 8 9 0])
> 3
> > >>> nil 6 'a 0 "z" 2 5)))
> > >>> Evaluation count : 68844120 in 60 samples of 1147402 calls.
> > >>>Execution time mean : 893.798444 ns
> > >>>   Execution time std-deviation : 24.566655 ns
> > >>>  Execution time lower quantile : 848.307600 ns ( 2.5%)
> > >>>  Execution time upper quantile : 952.841308 ns (97.5%)
> > >>>
> > >>> Found 13 outliers in 60 samples (21.6667 %)
> > >>>   low-severe 7 (11.6667 %)
> > >>>   low-mild 6 (10. %)
> > >>>Variance from outliers : 14.2244 % Variance is moderately
> inflated by
> > >>> outliers
> > >>> nil
> > >>> user=> (bench (assoc [1 2 3 4 5 6 7 8 9 0] 3 nil 6 'a 0 "z" 2 5 4
> (atom
> > >>> []) 7 "v")) ;;6 operations
> > >>> Evaluation count : 39783840 in 60 samples of 663064 calls.
> > >>>Execution time mean : 1.480511 us
> > >>>   Execution time std-deviation : 50.249443 ns
> > >>>  Execution time lower quantile : 1.425053 us ( 2.5%)
> > >>>  Execution time upper quantile : 1.591407

Re: transient/persistent! not worth for less than 7-8 operations

2012-11-09 Thread Softaddicts
Ubuntu 12.04, java 6 32 bits

Luc P.


> This is weird...for just 2 operations I'm getting consistently better 
> timings with persistent than transients...
> 
> user=> (time (dotimes [_ 100] (assoc [1 2 3 4 5 6 7 8 9 0] 3 5 6 8)))
> "Elapsed time: 240.247405 msecs"
> nil
> user=>
> user=> (time (dotimes [_ 100] (persistent! (assoc! (transient [1 2 3 
> 4 5 6 7 8 9 0]) 3 5 6 8
> "Elapsed time: 354.122806 msecs"
> nil
> user=> (time (dotimes [_ 100] (assoc [1 2 3 4 5 6 7 8 9 0] 3 5 6 8)))
> "Elapsed time: 188.765493 msecs"
> nil
> user=> (time (dotimes [_ 100] (persistent! (assoc! (transient [1 2 3 
> 4 5 6 7 8 9 0]) 3 5 6 8
> "Elapsed time: 318.90242 msecs"
> nil
> 
> Jim
> 
> ps: are you guys on java 1.7 ?
> 
> On 09/11/12 02:29, Softaddicts wrote:
> > Roughly... My FPU module is slow tonight
> >
> >
> >> My own tests shows that the transient version is twice as fast:
> >>
> >> (time (dotimes [_ 100] (assoc [1 2 3 4 5 6 7 8 9 0] 3 5 6 8)))
> >> Elapsed time: 711.848312 msecs
> >>
> >> (time (dotimes [_ 100] (persistent! (assoc! (transient [1 2 3 4 5 6 7 
> >> 8 9 0]) 3 5 6 8
> >> Elapsed time: 399.466556 msecs
> >>
> >> Luc P.
> >>
> >>> user=>  (use '[criterium.core])
> >>> nil
> >>> user=> (bench (assoc [1 2 3 4 5 6 7 8 9 0] 3 nil 6 'a)) ;;2 operations
> >>>
> >>> Evaluation count : 125829120 in 60 samples of 2097152 calls.
> >>>Execution time mean : 488.826554 ns
> >>>   Execution time std-deviation : 19.952095 ns
> >>>  Execution time lower quantile : 459.910320 ns ( 2.5%)
> >>>  Execution time upper quantile : 527.008269 ns (97.5%)
> >>> nil
> >>> user=> (bench (persistent! (assoc! (transient [1 2 3 4 5 6 7 8 9 0]) 3
> >>> nil 6 'a)))
> >>> Evaluation count : 97399860 in 60 samples of 1623331 calls.
> >>>Execution time mean : 639.789263 ns
> >>>   Execution time std-deviation : 26.265080 ns
> >>>  Execution time lower quantile : 597.753127 ns ( 2.5%)
> >>>  Execution time upper quantile : 687.838668 ns (97.5%)
> >>> nil
> >>> user=> (bench (assoc [1 2 3 4 5 6 7 8 9 0] 3 nil 6 'a 0 "z" 2 5)) ;;4
> >>> operations
> >>> Evaluation count : 68275920 in 60 samples of 1137932 calls.
> >>>Execution time mean : 901.407416 ns
> >>>   Execution time std-deviation : 35.682637 ns
> >>>  Execution time lower quantile : 851.060950 ns ( 2.5%)
> >>>  Execution time upper quantile : 970.492949 ns (97.5%)
> >>>
> >>> Found 1 outliers in 60 samples (1.6667 %)
> >>>   low-severe 1 (1.6667 %)
> >>>Variance from outliers : 25.4849 % Variance is moderately inflated by
> >>> outliers
> >>> nil
> >>> user=> (bench (persistent! (assoc! (transient [1 2 3 4 5 6 7 8 9 0]) 3
> >>> nil 6 'a 0 "z" 2 5)))
> >>> Evaluation count : 68844120 in 60 samples of 1147402 calls.
> >>>Execution time mean : 893.798444 ns
> >>>   Execution time std-deviation : 24.566655 ns
> >>>  Execution time lower quantile : 848.307600 ns ( 2.5%)
> >>>  Execution time upper quantile : 952.841308 ns (97.5%)
> >>>
> >>> Found 13 outliers in 60 samples (21.6667 %)
> >>>   low-severe 7 (11.6667 %)
> >>>   low-mild 6 (10. %)
> >>>Variance from outliers : 14.2244 % Variance is moderately inflated by
> >>> outliers
> >>> nil
> >>> user=> (bench (assoc [1 2 3 4 5 6 7 8 9 0] 3 nil 6 'a 0 "z" 2 5 4 (atom
> >>> []) 7 "v")) ;;6 operations
> >>> Evaluation count : 39783840 in 60 samples of 663064 calls.
> >>>Execution time mean : 1.480511 us
> >>>   Execution time std-deviation : 50.249443 ns
> >>>  Execution time lower quantile : 1.425053 us ( 2.5%)
> >>>  Execution time upper quantile : 1.591407 us (97.5%)
> >>> nil
> >>> user=> (bench (persistent! (assoc! (transient [1 2 3 4 5 6 7 8 9 0]) 3
> >>> nil 6 'a 0 "z" 2 5 4 (atom []) 7 "v")))
> >>> Evaluation count : 44755020 in 60 samples of 745917 calls.
> >>>Execution time mean : 1.358394 us
> >>>   Execution time std-deviation : 49.723547 ns
> >>>  Execution time lower quantile : 1.306456 us ( 2.5%)
> >>>  Execution time upper quantile : 1.473882 us (97.5%)
> >>> nil
> >>>
> >>> user=> (bench (assoc [1 2 3 4 5 6 7 8 9 0] 3 nil 6 'a 0 "z" 2 5 4 (atom
> >>> []) 7 "v" 5 1200 8 -)) ;;8 operations
> >>> Evaluation count : 31457280 in 60 samples of 524288 calls.
> >>>Execution time mean : 1.907389 us
> >>>   Execution time std-deviation : 74.523511 ns
> >>>  Execution time lower quantile : 1.822336 us ( 2.5%)
> >>>  Execution time upper quantile : 2.076044 us (97.5%)
> >>> nil
> >>> user=> (bench (persistent! (assoc! (transient [1 2 3 4 5 6 7 8 9 0]) 3
> >>> nil 6 'a 0 "z" 2 5 4 (atom []) 7 "v" 5 1200 8 -)))
> >>> Evaluation count : 37739640 in 60 samples of 628994 calls.
> >>>Execution time mean : 1.623599 us
> >>>   Execution time std-deviation : 68.677518 ns
> >>>  Execution time lower quantile : 1.529454 us ( 2.5%)
> >>> 

Re: transient/persistent! not worth for less than 7-8 operations

2012-11-09 Thread Jim - FooBar();
This is weird...for just 2 operations I'm getting consistently better 
timings with persistent than transients...


user=> (time (dotimes [_ 100] (assoc [1 2 3 4 5 6 7 8 9 0] 3 5 6 8)))
"Elapsed time: 240.247405 msecs"
nil
user=>
user=> (time (dotimes [_ 100] (persistent! (assoc! (transient [1 2 3 
4 5 6 7 8 9 0]) 3 5 6 8

"Elapsed time: 354.122806 msecs"
nil
user=> (time (dotimes [_ 100] (assoc [1 2 3 4 5 6 7 8 9 0] 3 5 6 8)))
"Elapsed time: 188.765493 msecs"
nil
user=> (time (dotimes [_ 100] (persistent! (assoc! (transient [1 2 3 
4 5 6 7 8 9 0]) 3 5 6 8

"Elapsed time: 318.90242 msecs"
nil

Jim

ps: are you guys on java 1.7 ?

On 09/11/12 02:29, Softaddicts wrote:

Roughly... My FPU module is slow tonight



My own tests shows that the transient version is twice as fast:

(time (dotimes [_ 100] (assoc [1 2 3 4 5 6 7 8 9 0] 3 5 6 8)))
Elapsed time: 711.848312 msecs

(time (dotimes [_ 100] (persistent! (assoc! (transient [1 2 3 4 5 6 7 8 9 
0]) 3 5 6 8
Elapsed time: 399.466556 msecs

Luc P.


user=>  (use '[criterium.core])
nil
user=> (bench (assoc [1 2 3 4 5 6 7 8 9 0] 3 nil 6 'a)) ;;2 operations

Evaluation count : 125829120 in 60 samples of 2097152 calls.
   Execution time mean : 488.826554 ns
  Execution time std-deviation : 19.952095 ns
 Execution time lower quantile : 459.910320 ns ( 2.5%)
 Execution time upper quantile : 527.008269 ns (97.5%)
nil
user=> (bench (persistent! (assoc! (transient [1 2 3 4 5 6 7 8 9 0]) 3
nil 6 'a)))
Evaluation count : 97399860 in 60 samples of 1623331 calls.
   Execution time mean : 639.789263 ns
  Execution time std-deviation : 26.265080 ns
 Execution time lower quantile : 597.753127 ns ( 2.5%)
 Execution time upper quantile : 687.838668 ns (97.5%)
nil
user=> (bench (assoc [1 2 3 4 5 6 7 8 9 0] 3 nil 6 'a 0 "z" 2 5)) ;;4
operations
Evaluation count : 68275920 in 60 samples of 1137932 calls.
   Execution time mean : 901.407416 ns
  Execution time std-deviation : 35.682637 ns
 Execution time lower quantile : 851.060950 ns ( 2.5%)
 Execution time upper quantile : 970.492949 ns (97.5%)

Found 1 outliers in 60 samples (1.6667 %)
  low-severe 1 (1.6667 %)
   Variance from outliers : 25.4849 % Variance is moderately inflated by
outliers
nil
user=> (bench (persistent! (assoc! (transient [1 2 3 4 5 6 7 8 9 0]) 3
nil 6 'a 0 "z" 2 5)))
Evaluation count : 68844120 in 60 samples of 1147402 calls.
   Execution time mean : 893.798444 ns
  Execution time std-deviation : 24.566655 ns
 Execution time lower quantile : 848.307600 ns ( 2.5%)
 Execution time upper quantile : 952.841308 ns (97.5%)

Found 13 outliers in 60 samples (21.6667 %)
  low-severe 7 (11.6667 %)
  low-mild 6 (10. %)
   Variance from outliers : 14.2244 % Variance is moderately inflated by
outliers
nil
user=> (bench (assoc [1 2 3 4 5 6 7 8 9 0] 3 nil 6 'a 0 "z" 2 5 4 (atom
[]) 7 "v")) ;;6 operations
Evaluation count : 39783840 in 60 samples of 663064 calls.
   Execution time mean : 1.480511 us
  Execution time std-deviation : 50.249443 ns
 Execution time lower quantile : 1.425053 us ( 2.5%)
 Execution time upper quantile : 1.591407 us (97.5%)
nil
user=> (bench (persistent! (assoc! (transient [1 2 3 4 5 6 7 8 9 0]) 3
nil 6 'a 0 "z" 2 5 4 (atom []) 7 "v")))
Evaluation count : 44755020 in 60 samples of 745917 calls.
   Execution time mean : 1.358394 us
  Execution time std-deviation : 49.723547 ns
 Execution time lower quantile : 1.306456 us ( 2.5%)
 Execution time upper quantile : 1.473882 us (97.5%)
nil

user=> (bench (assoc [1 2 3 4 5 6 7 8 9 0] 3 nil 6 'a 0 "z" 2 5 4 (atom
[]) 7 "v" 5 1200 8 -)) ;;8 operations
Evaluation count : 31457280 in 60 samples of 524288 calls.
   Execution time mean : 1.907389 us
  Execution time std-deviation : 74.523511 ns
 Execution time lower quantile : 1.822336 us ( 2.5%)
 Execution time upper quantile : 2.076044 us (97.5%)
nil
user=> (bench (persistent! (assoc! (transient [1 2 3 4 5 6 7 8 9 0]) 3
nil 6 'a 0 "z" 2 5 4 (atom []) 7 "v" 5 1200 8 -)))
Evaluation count : 37739640 in 60 samples of 628994 calls.
   Execution time mean : 1.623599 us
  Execution time std-deviation : 68.677518 ns
 Execution time lower quantile : 1.529454 us ( 2.5%)
 Execution time upper quantile : 1.777040 us (97.5%)

Found 1 outliers in 60 samples (1.6667 %)
  low-severe 1 (1.6667 %)
   Variance from outliers : 28.6901 % Variance is moderately inflated by
outliers
nil


etc etc...

you get the idea...conclusion: there is no real benefit to using
transients for less than 6 operations...

Jim




On 08/11/12 23:04, Philip Potter wrote:

Share the benchmark!

In theory, conversion to and from transients should be constant time
operations, but it would not surprise me if in practice transients
aren't universally faster than persistent.

Performance 

Re: transient/persistent! not worth for less than 7-8 operations

2012-11-09 Thread Jim - FooBar();

No I'm on Ubuntu 12.04 64bit, oracle-java 7,  clojure 1.4...

Jim

On 09/11/12 03:36, Herwig Hochleitner wrote:
Hmm, this is the second (unverified) report of transients being slower 
than persistents.


Jim, are you on OSX too, by chance? Which JVM?
--
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 


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


Re: transient/persistent! not worth for less than 7-8 operations

2012-11-08 Thread Herwig Hochleitner
Hmm, this is the second (unverified) report of transients being slower than
persistents.

Jim, are you on OSX too, by chance? Which JVM?

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

Re: transient/persistent! not worth for less than 7-8 operations

2012-11-08 Thread Softaddicts
Roughly... My FPU module is slow tonight


> My own tests shows that the transient version is twice as fast:
> 
> (time (dotimes [_ 100] (assoc [1 2 3 4 5 6 7 8 9 0] 3 5 6 8)))
> Elapsed time: 711.848312 msecs
> 
> (time (dotimes [_ 100] (persistent! (assoc! (transient [1 2 3 4 5 6 7 8 9 
> 0]) 3 5 6 8
> Elapsed time: 399.466556 msecs
> 
> Luc P.
> 
> > user=>  (use '[criterium.core])
> > nil
> > user=> (bench (assoc [1 2 3 4 5 6 7 8 9 0] 3 nil 6 'a)) ;;2 operations
> > 
> > Evaluation count : 125829120 in 60 samples of 2097152 calls.
> >   Execution time mean : 488.826554 ns
> >  Execution time std-deviation : 19.952095 ns
> > Execution time lower quantile : 459.910320 ns ( 2.5%)
> > Execution time upper quantile : 527.008269 ns (97.5%)
> > nil
> > user=> (bench (persistent! (assoc! (transient [1 2 3 4 5 6 7 8 9 0]) 3 
> > nil 6 'a)))
> > Evaluation count : 97399860 in 60 samples of 1623331 calls.
> >   Execution time mean : 639.789263 ns
> >  Execution time std-deviation : 26.265080 ns
> > Execution time lower quantile : 597.753127 ns ( 2.5%)
> > Execution time upper quantile : 687.838668 ns (97.5%)
> > nil
> > user=> (bench (assoc [1 2 3 4 5 6 7 8 9 0] 3 nil 6 'a 0 "z" 2 5)) ;;4 
> > operations
> > Evaluation count : 68275920 in 60 samples of 1137932 calls.
> >   Execution time mean : 901.407416 ns
> >  Execution time std-deviation : 35.682637 ns
> > Execution time lower quantile : 851.060950 ns ( 2.5%)
> > Execution time upper quantile : 970.492949 ns (97.5%)
> > 
> > Found 1 outliers in 60 samples (1.6667 %)
> >  low-severe 1 (1.6667 %)
> >   Variance from outliers : 25.4849 % Variance is moderately inflated by 
> > outliers
> > nil
> > user=> (bench (persistent! (assoc! (transient [1 2 3 4 5 6 7 8 9 0]) 3 
> > nil 6 'a 0 "z" 2 5)))
> > Evaluation count : 68844120 in 60 samples of 1147402 calls.
> >   Execution time mean : 893.798444 ns
> >  Execution time std-deviation : 24.566655 ns
> > Execution time lower quantile : 848.307600 ns ( 2.5%)
> > Execution time upper quantile : 952.841308 ns (97.5%)
> > 
> > Found 13 outliers in 60 samples (21.6667 %)
> >  low-severe 7 (11.6667 %)
> >  low-mild 6 (10. %)
> >   Variance from outliers : 14.2244 % Variance is moderately inflated by 
> > outliers
> > nil
> > user=> (bench (assoc [1 2 3 4 5 6 7 8 9 0] 3 nil 6 'a 0 "z" 2 5 4 (atom 
> > []) 7 "v")) ;;6 operations
> > Evaluation count : 39783840 in 60 samples of 663064 calls.
> >   Execution time mean : 1.480511 us
> >  Execution time std-deviation : 50.249443 ns
> > Execution time lower quantile : 1.425053 us ( 2.5%)
> > Execution time upper quantile : 1.591407 us (97.5%)
> > nil
> > user=> (bench (persistent! (assoc! (transient [1 2 3 4 5 6 7 8 9 0]) 3 
> > nil 6 'a 0 "z" 2 5 4 (atom []) 7 "v")))
> > Evaluation count : 44755020 in 60 samples of 745917 calls.
> >   Execution time mean : 1.358394 us
> >  Execution time std-deviation : 49.723547 ns
> > Execution time lower quantile : 1.306456 us ( 2.5%)
> > Execution time upper quantile : 1.473882 us (97.5%)
> > nil
> > 
> > user=> (bench (assoc [1 2 3 4 5 6 7 8 9 0] 3 nil 6 'a 0 "z" 2 5 4 (atom 
> > []) 7 "v" 5 1200 8 -)) ;;8 operations
> > Evaluation count : 31457280 in 60 samples of 524288 calls.
> >   Execution time mean : 1.907389 us
> >  Execution time std-deviation : 74.523511 ns
> > Execution time lower quantile : 1.822336 us ( 2.5%)
> > Execution time upper quantile : 2.076044 us (97.5%)
> > nil
> > user=> (bench (persistent! (assoc! (transient [1 2 3 4 5 6 7 8 9 0]) 3 
> > nil 6 'a 0 "z" 2 5 4 (atom []) 7 "v" 5 1200 8 -)))
> > Evaluation count : 37739640 in 60 samples of 628994 calls.
> >   Execution time mean : 1.623599 us
> >  Execution time std-deviation : 68.677518 ns
> > Execution time lower quantile : 1.529454 us ( 2.5%)
> > Execution time upper quantile : 1.777040 us (97.5%)
> > 
> > Found 1 outliers in 60 samples (1.6667 %)
> >  low-severe 1 (1.6667 %)
> >   Variance from outliers : 28.6901 % Variance is moderately inflated by 
> > outliers
> > nil
> > 
> > 
> > etc etc...
> > 
> > you get the idea...conclusion: there is no real benefit to using 
> > transients for less than 6 operations...
> > 
> > Jim
> > 
> > 
> > 
> > 
> > On 08/11/12 23:04, Philip Potter wrote:
> > >
> > > Share the benchmark!
> > >
> > > In theory, conversion to and from transients should be constant time 
> > > operations, but it would not surprise me if in practice transients 
> > > aren't universally faster than persistent.
> > >
> > > Performance in different environments varies wildly, so I would doubt 
> > > results from a small benchmark on a single machine are universally 
> > > applicable.
> > >
> > > Benchmarking is hard, particularly on the jvm. Caching and dynamic 
> > > inlining and Hotspot confuse matters grea

Re: transient/persistent! not worth for less than 7-8 operations

2012-11-08 Thread Softaddicts
My own tests shows that the transient version is twice as fast:

(time (dotimes [_ 100] (assoc [1 2 3 4 5 6 7 8 9 0] 3 5 6 8)))
Elapsed time: 711.848312 msecs

(time (dotimes [_ 100] (persistent! (assoc! (transient [1 2 3 4 5 6 7 8 9 
0]) 3 5 6 8
Elapsed time: 399.466556 msecs

Luc P.

> user=>  (use '[criterium.core])
> nil
> user=> (bench (assoc [1 2 3 4 5 6 7 8 9 0] 3 nil 6 'a)) ;;2 operations
> 
> Evaluation count : 125829120 in 60 samples of 2097152 calls.
>   Execution time mean : 488.826554 ns
>  Execution time std-deviation : 19.952095 ns
> Execution time lower quantile : 459.910320 ns ( 2.5%)
> Execution time upper quantile : 527.008269 ns (97.5%)
> nil
> user=> (bench (persistent! (assoc! (transient [1 2 3 4 5 6 7 8 9 0]) 3 
> nil 6 'a)))
> Evaluation count : 97399860 in 60 samples of 1623331 calls.
>   Execution time mean : 639.789263 ns
>  Execution time std-deviation : 26.265080 ns
> Execution time lower quantile : 597.753127 ns ( 2.5%)
> Execution time upper quantile : 687.838668 ns (97.5%)
> nil
> user=> (bench (assoc [1 2 3 4 5 6 7 8 9 0] 3 nil 6 'a 0 "z" 2 5)) ;;4 
> operations
> Evaluation count : 68275920 in 60 samples of 1137932 calls.
>   Execution time mean : 901.407416 ns
>  Execution time std-deviation : 35.682637 ns
> Execution time lower quantile : 851.060950 ns ( 2.5%)
> Execution time upper quantile : 970.492949 ns (97.5%)
> 
> Found 1 outliers in 60 samples (1.6667 %)
>  low-severe 1 (1.6667 %)
>   Variance from outliers : 25.4849 % Variance is moderately inflated by 
> outliers
> nil
> user=> (bench (persistent! (assoc! (transient [1 2 3 4 5 6 7 8 9 0]) 3 
> nil 6 'a 0 "z" 2 5)))
> Evaluation count : 68844120 in 60 samples of 1147402 calls.
>   Execution time mean : 893.798444 ns
>  Execution time std-deviation : 24.566655 ns
> Execution time lower quantile : 848.307600 ns ( 2.5%)
> Execution time upper quantile : 952.841308 ns (97.5%)
> 
> Found 13 outliers in 60 samples (21.6667 %)
>  low-severe 7 (11.6667 %)
>  low-mild 6 (10. %)
>   Variance from outliers : 14.2244 % Variance is moderately inflated by 
> outliers
> nil
> user=> (bench (assoc [1 2 3 4 5 6 7 8 9 0] 3 nil 6 'a 0 "z" 2 5 4 (atom 
> []) 7 "v")) ;;6 operations
> Evaluation count : 39783840 in 60 samples of 663064 calls.
>   Execution time mean : 1.480511 us
>  Execution time std-deviation : 50.249443 ns
> Execution time lower quantile : 1.425053 us ( 2.5%)
> Execution time upper quantile : 1.591407 us (97.5%)
> nil
> user=> (bench (persistent! (assoc! (transient [1 2 3 4 5 6 7 8 9 0]) 3 
> nil 6 'a 0 "z" 2 5 4 (atom []) 7 "v")))
> Evaluation count : 44755020 in 60 samples of 745917 calls.
>   Execution time mean : 1.358394 us
>  Execution time std-deviation : 49.723547 ns
> Execution time lower quantile : 1.306456 us ( 2.5%)
> Execution time upper quantile : 1.473882 us (97.5%)
> nil
> 
> user=> (bench (assoc [1 2 3 4 5 6 7 8 9 0] 3 nil 6 'a 0 "z" 2 5 4 (atom 
> []) 7 "v" 5 1200 8 -)) ;;8 operations
> Evaluation count : 31457280 in 60 samples of 524288 calls.
>   Execution time mean : 1.907389 us
>  Execution time std-deviation : 74.523511 ns
> Execution time lower quantile : 1.822336 us ( 2.5%)
> Execution time upper quantile : 2.076044 us (97.5%)
> nil
> user=> (bench (persistent! (assoc! (transient [1 2 3 4 5 6 7 8 9 0]) 3 
> nil 6 'a 0 "z" 2 5 4 (atom []) 7 "v" 5 1200 8 -)))
> Evaluation count : 37739640 in 60 samples of 628994 calls.
>   Execution time mean : 1.623599 us
>  Execution time std-deviation : 68.677518 ns
> Execution time lower quantile : 1.529454 us ( 2.5%)
> Execution time upper quantile : 1.777040 us (97.5%)
> 
> Found 1 outliers in 60 samples (1.6667 %)
>  low-severe 1 (1.6667 %)
>   Variance from outliers : 28.6901 % Variance is moderately inflated by 
> outliers
> nil
> 
> 
> etc etc...
> 
> you get the idea...conclusion: there is no real benefit to using 
> transients for less than 6 operations...
> 
> Jim
> 
> 
> 
> 
> On 08/11/12 23:04, Philip Potter wrote:
> >
> > Share the benchmark!
> >
> > In theory, conversion to and from transients should be constant time 
> > operations, but it would not surprise me if in practice transients 
> > aren't universally faster than persistent.
> >
> > Performance in different environments varies wildly, so I would doubt 
> > results from a small benchmark on a single machine are universally 
> > applicable.
> >
> > Benchmarking is hard, particularly on the jvm. Caching and dynamic 
> > inlining and Hotspot confuse matters greatly.
> >
> > Phil
> >
> > On Nov 8, 2012 10:49 PM, "Jim - FooBar();"  > > wrote:
> >
> > Some quick benchmarking that I did, showed that it is actually
> > more expensive to convert to transient, conj/assoc and convert
> > back to persistent than

Re: transient/persistent! not worth for less than 7-8 operations

2012-11-08 Thread Jim - FooBar();

user=>  (use '[criterium.core])
nil
user=> (bench (assoc [1 2 3 4 5 6 7 8 9 0] 3 nil 6 'a)) ;;2 operations

Evaluation count : 125829120 in 60 samples of 2097152 calls.
 Execution time mean : 488.826554 ns
Execution time std-deviation : 19.952095 ns
   Execution time lower quantile : 459.910320 ns ( 2.5%)
   Execution time upper quantile : 527.008269 ns (97.5%)
nil
user=> (bench (persistent! (assoc! (transient [1 2 3 4 5 6 7 8 9 0]) 3 
nil 6 'a)))

Evaluation count : 97399860 in 60 samples of 1623331 calls.
 Execution time mean : 639.789263 ns
Execution time std-deviation : 26.265080 ns
   Execution time lower quantile : 597.753127 ns ( 2.5%)
   Execution time upper quantile : 687.838668 ns (97.5%)
nil
user=> (bench (assoc [1 2 3 4 5 6 7 8 9 0] 3 nil 6 'a 0 "z" 2 5)) ;;4 
operations

Evaluation count : 68275920 in 60 samples of 1137932 calls.
 Execution time mean : 901.407416 ns
Execution time std-deviation : 35.682637 ns
   Execution time lower quantile : 851.060950 ns ( 2.5%)
   Execution time upper quantile : 970.492949 ns (97.5%)

Found 1 outliers in 60 samples (1.6667 %)
low-severe 1 (1.6667 %)
 Variance from outliers : 25.4849 % Variance is moderately inflated by 
outliers

nil
user=> (bench (persistent! (assoc! (transient [1 2 3 4 5 6 7 8 9 0]) 3 
nil 6 'a 0 "z" 2 5)))

Evaluation count : 68844120 in 60 samples of 1147402 calls.
 Execution time mean : 893.798444 ns
Execution time std-deviation : 24.566655 ns
   Execution time lower quantile : 848.307600 ns ( 2.5%)
   Execution time upper quantile : 952.841308 ns (97.5%)

Found 13 outliers in 60 samples (21.6667 %)
low-severe 7 (11.6667 %)
low-mild 6 (10. %)
 Variance from outliers : 14.2244 % Variance is moderately inflated by 
outliers

nil
user=> (bench (assoc [1 2 3 4 5 6 7 8 9 0] 3 nil 6 'a 0 "z" 2 5 4 (atom 
[]) 7 "v")) ;;6 operations

Evaluation count : 39783840 in 60 samples of 663064 calls.
 Execution time mean : 1.480511 us
Execution time std-deviation : 50.249443 ns
   Execution time lower quantile : 1.425053 us ( 2.5%)
   Execution time upper quantile : 1.591407 us (97.5%)
nil
user=> (bench (persistent! (assoc! (transient [1 2 3 4 5 6 7 8 9 0]) 3 
nil 6 'a 0 "z" 2 5 4 (atom []) 7 "v")))

Evaluation count : 44755020 in 60 samples of 745917 calls.
 Execution time mean : 1.358394 us
Execution time std-deviation : 49.723547 ns
   Execution time lower quantile : 1.306456 us ( 2.5%)
   Execution time upper quantile : 1.473882 us (97.5%)
nil

user=> (bench (assoc [1 2 3 4 5 6 7 8 9 0] 3 nil 6 'a 0 "z" 2 5 4 (atom 
[]) 7 "v" 5 1200 8 -)) ;;8 operations

Evaluation count : 31457280 in 60 samples of 524288 calls.
 Execution time mean : 1.907389 us
Execution time std-deviation : 74.523511 ns
   Execution time lower quantile : 1.822336 us ( 2.5%)
   Execution time upper quantile : 2.076044 us (97.5%)
nil
user=> (bench (persistent! (assoc! (transient [1 2 3 4 5 6 7 8 9 0]) 3 
nil 6 'a 0 "z" 2 5 4 (atom []) 7 "v" 5 1200 8 -)))

Evaluation count : 37739640 in 60 samples of 628994 calls.
 Execution time mean : 1.623599 us
Execution time std-deviation : 68.677518 ns
   Execution time lower quantile : 1.529454 us ( 2.5%)
   Execution time upper quantile : 1.777040 us (97.5%)

Found 1 outliers in 60 samples (1.6667 %)
low-severe 1 (1.6667 %)
 Variance from outliers : 28.6901 % Variance is moderately inflated by 
outliers

nil


etc etc...

you get the idea...conclusion: there is no real benefit to using 
transients for less than 6 operations...


Jim




On 08/11/12 23:04, Philip Potter wrote:


Share the benchmark!

In theory, conversion to and from transients should be constant time 
operations, but it would not surprise me if in practice transients 
aren't universally faster than persistent.


Performance in different environments varies wildly, so I would doubt 
results from a small benchmark on a single machine are universally 
applicable.


Benchmarking is hard, particularly on the jvm. Caching and dynamic 
inlining and Hotspot confuse matters greatly.


Phil

On Nov 8, 2012 10:49 PM, "Jim - FooBar();" > wrote:


Some quick benchmarking that I did, showed that it is actually
more expensive to convert to transient, conj/assoc and convert
back to persistent than the regular conj/assoc unless you want to
do more than 8 operations at a time (preferably more than that).
My experiments were on vectors and the vararg version of assoc/assoc!.

any thoughts? would you agree?

Jim

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

Re: transient/persistent! not worth for less than 7-8 operations

2012-11-08 Thread Softaddicts
We systematically use them. Our typical use case however is way above this
threshold. The policy here is that it cannot be worse than the persistent 
version.

Luc P


> Some quick benchmarking that I did, showed that it is actually more 
> expensive to convert to transient, conj/assoc and convert back to 
> persistent than the regular conj/assoc unless you want to do more than 8 
> operations at a time (preferably more than that). My experiments were on 
> vectors and the vararg version of assoc/assoc!.
> 
> any thoughts? would you agree?
> 
> Jim
> 
> -- 
> 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
> 
--
Softaddicts sent by ibisMail from my ipad!

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


Re: transient/persistent! not worth for less than 7-8 operations

2012-11-08 Thread Philip Potter
Share the benchmark!

In theory, conversion to and from transients should be constant time
operations, but it would not surprise me if in practice transients aren't
universally faster than persistent.

Performance in different environments varies wildly, so I would doubt
results from a small benchmark on a single machine are universally
applicable.

Benchmarking is hard, particularly on the jvm. Caching and dynamic inlining
and Hotspot confuse matters greatly.

Phil
 On Nov 8, 2012 10:49 PM, "Jim - FooBar();"  wrote:

> Some quick benchmarking that I did, showed that it is actually more
> expensive to convert to transient, conj/assoc and convert back to
> persistent than the regular conj/assoc unless you want to do more than 8
> operations at a time (preferably more than that). My experiments were on
> vectors and the vararg version of assoc/assoc!.
>
> any thoughts? would you agree?
>
> Jim
>
> --
> 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+unsubscribe@**googlegroups.com
> For more options, visit this group at
> http://groups.google.com/**group/clojure?hl=en
>

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