synapse-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andreas Veithen (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (SYNAPSE-1102) Performance save - Replace instances of Math.Random with Random.nextDouble
Date Sat, 11 May 2019 09:56:00 GMT

    [ https://issues.apache.org/jira/browse/SYNAPSE-1102?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16837798#comment-16837798
] 

Andreas Veithen commented on SYNAPSE-1102:
------------------------------------------

Your patch replaces {{Math.random()}} with {{new Random().nextDouble()}}. {{Math.random()}}
has some overhead because it uses a shared {{Random}} instance and requires synchronization,
but this only becomes relevant under high concurrency. {{new Random().nextDouble()}} has overhead
because of object creation. It's not clear to me why that would be better. Probably the universally
better solution would be to use {{ThreadLocalRandom.current().nextDouble()}}.

> Performance save - Replace instances of Math.Random with Random.nextDouble
> --------------------------------------------------------------------------
>
>                 Key: SYNAPSE-1102
>                 URL: https://issues.apache.org/jira/browse/SYNAPSE-1102
>             Project: Synapse
>          Issue Type: Improvement
>            Reporter: bd2019us
>            Assignee: Isuru Udana Loku Narangoda
>            Priority: Trivial
>         Attachments: SYNAPSE-1102.patch
>
>
> Some slight performance can be saved when replacing Math.random with Random.nextDouble,
due to Math.random not having to create an instance of Random.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@synapse.apache.org
For additional commands, e-mail: dev-help@synapse.apache.org


Mime
View raw message