Skip to content

Commit

Permalink
common: Use double instead of long double to improve performance
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
fengchunsong committed Jun 29, 2021
1 parent 566a8a9 commit 58753cf
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/include/utime.h
Expand Up @@ -224,7 +224,7 @@ class utime_t {

// 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;
Expand Down

0 comments on commit 58753cf

Please sign in to comment.