You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cloudstack.apache.org by "bd2019us (JIRA)" <ji...@apache.org> on 2019/04/12 05:19:00 UTC

[jira] [Updated] (CLOUDSTACK-10407) Date.getTime() can be changed to System.currentTimeMillis()

     [ https://issues.apache.org/jira/browse/CLOUDSTACK-10407?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

bd2019us updated CLOUDSTACK-10407:
----------------------------------
    Description: 
Location:  server/src/main/java/com/cloud/api/ApiServer.java:1082

Hello,
In this file location, only getTime() is used for Date object, in this case, the light method System.currentTimeMillis() is recommended, which can avoid creating the temporary Date object.  new Date() is a thin wrapper of method System.currentTimeMillis(). The performance will be greatly damaged if it is invoked too much times.
According to my local testing at the same environment, System.currentTimeMillis() can achieve a speedup to 5 times (435ms vs 2073ms), when these two methods are invoked 5,000,000 times.


  was:
Location:  server/src/main/java/com/cloud/api/ApiServer.java:1082

Hello,
In this file location, only getTime() is used for Date object, in this case, the light method System.currentTimeMillis() is recommended, which can avoid creating the temporary Date object.   Since new Date() is a thin wrapper of method System.currentTimeMillis(). The performance will be greatly damaged if it is invoked too much times.
According to my local testing at the same environment, System.currentTimeMillis() can achieve a speedup to 5 times (435ms vs 2073ms), when these two methods are invoked 5,000,000 times.



> Date.getTime() can be changed to System.currentTimeMillis()
> -----------------------------------------------------------
>
>                 Key: CLOUDSTACK-10407
>                 URL: https://issues.apache.org/jira/browse/CLOUDSTACK-10407
>             Project: CloudStack
>          Issue Type: Bug
>      Security Level: Public(Anyone can view this level - this is the default.) 
>            Reporter: bd2019us
>            Priority: Major
>
> Location:  server/src/main/java/com/cloud/api/ApiServer.java:1082
> Hello,
> In this file location, only getTime() is used for Date object, in this case, the light method System.currentTimeMillis() is recommended, which can avoid creating the temporary Date object.  new Date() is a thin wrapper of method System.currentTimeMillis(). The performance will be greatly damaged if it is invoked too much times.
> According to my local testing at the same environment, System.currentTimeMillis() can achieve a speedup to 5 times (435ms vs 2073ms), when these two methods are invoked 5,000,000 times.



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