Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [january-dev] clone() vs System.arraycopy

I have only skimmed the article but he concludes:


This leads me to conclude that the only reason why Paul's test seemed so much faster was because he picked a byte[] size that was small enough that the actual copying was dwarfed by the two if statements. Using clone() for copying arrays is less code and the performance difference is, as we saw, only significant for tiny arrays. I think that in future I will rather use clone() than System.arrayCopy().




From: january-dev-bounces@xxxxxxxxxxx [mailto:january-dev-bounces@xxxxxxxxxxx] On Behalf Of Matthew Gerring
Sent: 17 October 2017 11:35
To: january developer discussions <january-dev@xxxxxxxxxxx>
Subject: [january-dev] clone() vs System.arraycopy




January uses clone() quite a bit when duplicating large primitive arrays. For one of many instances see FloatDataset:

odata = data = "">


However System.arraycopy is ~5x faster according to:


Are there any plans to migrate from clone to arraycopy? Or do I have to submit a PR to do that? I might ask one of the team here to submit that change if you agree, please let me know you thoughts.





This e-mail and any attachments may contain confidential, copyright and or privileged material, and are for the use of the intended addressee only. If you are not the intended addressee or an authorised recipient of the addressee please notify us of receipt by returning the e-mail and do not use, copy, retain, distribute or disclose the information in or attached to the e-mail.
Any opinions expressed within this e-mail are those of the individual and not necessarily of Diamond Light Source Ltd.
Diamond Light Source Ltd. cannot guarantee that this e-mail or any attachments are free from viruses and we cannot accept liability for any damage which you may sustain as a result of software viruses which may be transmitted in or with the message.
Diamond Light Source Limited (company no. 4375679). Registered in England and Wales with its registered office at Diamond House, Harwell Science and Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United Kingdom

Back to the top