Hi,

On 17 Nov., 09:44, Laurent PETIT <laurent.pe...@gmail.com> wrote:

> I don't know.
>
> But my thougts were just that if you want to measure the time for a
> particular way "W" of coding things (and a variant "Wv"), and you test this
> with other computations "OC",
>
> then
> (not=
>   (/ (time Wv)
>      (time W))
>   (/ (+ (time Wv) (time OC))
>      (+ (time W) (time OC))))
>
> ?
>
> Especially if (time OC) is non neglictible ... ?

This is a valid concern. I did another test run, where really only the
traversal and the access is done in the benchmark. But to be honest:
my gut feeling sound the alarm bells about "do you test what you claim
you test or does HotSpot do its magic and optimises things away?"

user=> (let [s (doall (take 10000 (range)))]
         (bench
           (loop [s s i 0]
             (if (empty? s)
               i
               (recur (rest s) (first s))))))
Evaluation count             : 42060
Execution time mean          : 1,423636 ms  95,0% CI: (1,423576 ms,
1,423708 ms)
Execution time std-deviation : 236,456463 us  95,0% CI: (235,124875
us, 238,050869 us)

Found 4 outliers in 60 samples (6,6667 %)
        low-severe       4 (6,6667 %)
 Variance from outliers : 1,6389 % Variance is slightly inflated by
outliers
nil
user=> (let [s (doall (take 10000 (range)))]
         (bench
           (loop [s (seq s) i 0]
             (if s
               (recur (next s) (first s))
               i))))
Evaluation count             : 77100
Execution time mean          : 801,433279 us  95,0% CI: (801,390707
us, 801,464994 us)
Execution time std-deviation : 156,316400 us  95,0% CI: (154,780303
us, 158,550059 us)

Found 2 outliers in 60 samples (3,3333 %)
        low-severe       1 (1,6667 %)
        low-mild         1 (1,6667 %)
 Variance from outliers : 1,6389 % Variance is slightly inflated by
outliers
nil

That means:

0.801433279ms / 1.423636ms ~ 0.56 => 44% improvement?

Meikel

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