Code with reflection is ~6% faster on server JRE (in 1.9.0-RC1) and ~1%
slower on client JRE.
So apparently it's not a big deal.

Server JRE:

user> *clojure-version*
{:major 1, :minor 8, :incremental 0, :qualifier nil}
user> (use 'criterium.core)
nil
user> (bench (.length (.toString (reduce (fn [sb st] (.append sb st))
(StringBuilder.) (take 100000 (repeat "test"))))))
Reflection warning, *cider-repl scan*:396:54 - call to method append can't
be resolved (target class is unknown).
Reflection warning, *cider-repl scan*:396:23 - reference to field toString
can't be resolved.
Reflection warning, *cider-repl scan*:396:14 - reference to field length
can't be resolved.
Evaluation count : 60 in 60 samples of 1 calls.
             Execution time mean : 1.072324 sec
    Execution time std-deviation : 5.929780 ms
   Execution time lower quantile : 1.066123 sec ( 2.5%)
   Execution time upper quantile : 1.087542 sec (97.5%)
                   Overhead used : 1.598266 ns

Found 2 outliers in 60 samples (3.3333 %)
    low-severe     2 (3.3333 %)
 Variance from outliers : 1.6389 % Variance is slightly inflated by outliers

user> *clojure-version*
{:major 1, :minor 9, :incremental 0, :qualifier "RC1"}
user> (use 'criterium.core)
nil
user> (bench (.length (.toString (reduce (fn [sb st] (.append sb st))
(StringBuilder.) (take 100000 (repeat "test"))))))
Reflection warning, *cider-repl scan*<2>:418:54 - call to method append
can't be resolved (target class is unknown).
Reflection warning, *cider-repl scan*<2>:418:23 - reference to field
toString can't be resolved.
Reflection warning, *cider-repl scan*<2>:418:14 - reference to field length
can't be resolved.
Evaluation count : 60 in 60 samples of 1 calls.
             Execution time mean : 1.017560 sec
    Execution time std-deviation : 3.256887 ms
   Execution time lower quantile : 1.015164 sec ( 2.5%)
   Execution time upper quantile : 1.025247 sec (97.5%)
                   Overhead used : 1.598209 ns

Found 11 outliers in 60 samples (18.3333 %)
    low-severe     7 (11.6667 %)
    low-mild     4 (6.6667 %)
 Variance from outliers : 1.6389 % Variance is slightly inflated by outliers



Client JRE:

user> *clojure-version*
{:major 1, :minor 8, :incremental 0, :qualifier nil}
user> (use 'criterium.core)
nil
user> (bench (.length (.toString (reduce (fn [sb st] (.append sb st))
(StringBuilder.) (take 100000 (repeat "test"))))))
Reflection warning, *cider-repl scan*<2>:372:54 - call to method append
can't be resolved (target class is unknown).
Reflection warning, *cider-repl scan*<2>:372:23 - reference to field
toString can't be resolved.
Reflection warning, *cider-repl scan*<2>:372:14 - reference to field length
can't be resolved.
Evaluation count : 60 in 60 samples of 1 calls.
             Execution time mean : 4.468317 sec
    Execution time std-deviation : 9.396613 ms
   Execution time lower quantile : 4.460775 sec ( 2.5%)
   Execution time upper quantile : 4.491945 sec (97.5%)
                   Overhead used : 8.161463 ns

Found 9 outliers in 60 samples (15.0000 %)
    low-severe     6 (10.0000 %)
    low-mild     3 (5.0000 %)
 Variance from outliers : 1.6389 % Variance is slightly inflated by outliers

user> *clojure-version*
{:major 1, :minor 9, :incremental 0, :qualifier "RC1"}
user> (use 'criterium.core)
nil
user> (bench (.length (.toString (reduce (fn [sb st] (.append sb st))
(StringBuilder.) (take 100000 (repeat "test"))))))
Reflection warning, *cider-repl scan*:350:54 - call to method append can't
be resolved (target class is unknown).
Reflection warning, *cider-repl scan*:350:23 - reference to field toString
can't be resolved.
Reflection warning, *cider-repl scan*:350:14 - reference to field length
can't be resolved.
Evaluation count : 60 in 60 samples of 1 calls.
             Execution time mean : 4.504926 sec
    Execution time std-deviation : 10.412995 ms
   Execution time lower quantile : 4.488528 sec ( 2.5%)
   Execution time upper quantile : 4.532106 sec (97.5%)
                   Overhead used : 8.425136 ns

Found 3 outliers in 60 samples (5.0000 %)
    low-severe     3 (5.0000 %)
 Variance from outliers : 1.6389 % Variance is slightly inflated by outliers


On Fri, Nov 24, 2017 at 4:05 AM, Alex Miller <a...@puredanger.com> wrote:

> So is there any difference in this code between 1.8 and 1.9?
>
> On Nov 23, 2017, at 5:31 PM, Sergey Didenko <sergey.dide...@gmail.com>
> wrote:
>
> Correction - it's not about regex parsing. I removed reflection calls for
> StringBuilder and now it seems to be on par in speed.
>
> On Fri, Nov 24, 2017 at 1:20 AM, Sergey Didenko <sergey.dide...@gmail.com>
> wrote:
>
>> Hi,
>>
>> is it expected that code which does a lot of regex parsing is ~14% slower
>> than it was under Clojure 1.8?
>>
>> On Tue, Nov 14, 2017 at 8:22 AM, Shantanu Kumar <kumar.shant...@gmail.com
>> > wrote:
>>
>>> Sorry, my bad. I can see the same behavior in previous Clojure versions
>>> too. I discovered this in the middle of moving to 1.9.0-RC1 in one of
>>> the projects and somehow got it all mixed up.
>>>
>>>
>>> Shantanu
>>>
>>> On Tuesday, 14 November 2017 11:36:30 UTC+5:30, Andy Fingerhut wrote:
>>>>
>>>> I see the same behavior in Clojure 1.7.0 and 1.8.0 as you see in
>>>> 1.9.0-RC1.
>>>>
>>>> Andy
>>>>
>>>> On Mon, Nov 13, 2017 at 9:48 PM, Shantanu Kumar <kumar.s...@gmail.com>
>>>> wrote:
>>>>
>>>>> Sorry, I did not specify the problem completely earlier. The coercion
>>>>> fails only when *uncheked-math* is set to truthy in 1.9.0-RC1.
>>>>>
>>>>> user=> (byte \a)
>>>>> 97
>>>>> user=> (set! *unchecked-math* true)  ; or :warn-on-boxed
>>>>> true
>>>>> user=> (byte \a)
>>>>>
>>>>> ClassCastException java.lang.Character cannot be cast to
>>>>> java.lang.Number  clojure.lang.RT.uncheckedByteCast (RT.java:1376)
>>>>>
>>>>>
>>>>> Shantanu
>>>>>
>>>>> On Tuesday, 14 November 2017 01:27:36 UTC+5:30, Alex Miller wrote:
>>>>>>
>>>>>> Works for me in 1.9.0-RC1. I don't know of anything that changed in
>>>>>> this area.
>>>>>>
>>>>>> Clojure 1.9.0-RC1
>>>>>> user=> (byte \a)
>>>>>> 97
>>>>>>
>>>>>> On Mon, Nov 13, 2017 at 1:09 PM, Shantanu Kumar <kumar.s...@gmail.com
>>>>>> > wrote:
>>>>>>
>>>>>>> The coercion (byte \a) works fine in Clojure 1.8, but it fails with
>>>>>>> `ClassCastException java.lang.Character cannot be cast to 
>>>>>>> java.lang.Number`
>>>>>>> in 1.9.0-RC1. Is this by design?
>>>>>>>
>>>>>>>
>>>>>>> Shantanu
>>>>>>>
>>>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Clojure" group.
>>>>> To post to this group, send email to clo...@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+u...@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 unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to clojure+u...@googlegroups.com.
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>
>>>> --
>>> 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 unsubscribe from this group and stop receiving emails from it, send
>>> an email to clojure+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
> --
> 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 a topic in the
> Google Groups "Clojure" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/clojure/tWcLAhnEzIs/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to