]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common: Use double instead of long double to improve performance 42082/head
authorChunsong Feng <fengchunsong@huawei.com>
Tue, 29 Jun 2021 03:26:07 +0000 (03:26 +0000)
committerChunsong Feng <fengchunsong@huawei.com>
Tue, 29 Jun 2021 03:26:07 +0000 (03:26 +0000)
To convert namoseconds to seconds, the precision needs to be 10,
and the precision of double is 15, which is enough to use.
On aarch64, double division uses the div instruction, while long
double uses the gcc buildin _divtf3, which has poor performance.
Therefore, use double instead of long double for better performance.

Signed-off-by: Chunsong Feng <fengchunsong@huawei.com>
src/include/utime.h

index 512149db03e3aa1be9451b7928a73a9bf528df53..fad66af7939ad65750723e57ddb4eb4449dedcb4 100644 (file)
@@ -224,7 +224,7 @@ public:
 
   // cast to double
   operator double() const {
-    return (double)sec() + ((double)nsec() / 1000000000.0L);
+    return (double)sec() + ((double)nsec() / 1000000000.0f);
   }
   operator ceph_timespec() const {
     ceph_timespec ts;