This is an automated email from the ASF dual-hosted git repository.

lihaopeng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 2208cde22e7 [Performance](func) opt the print_id func (#41302)
2208cde22e7 is described below

commit 2208cde22e7d8f85c7b62ee571d6dc7fd514b91f
Author: HappenLee <happen...@hotmail.com>
AuthorDate: Thu Sep 26 10:20:10 2024 +0800

    [Performance](func) opt the print_id func (#41302)
    
    Load Average: 52.48, 35.97, 38.43
    ------------------------------------------------------
    Benchmark            Time             CPU   Iterations
    ------------------------------------------------------
    old 3390427270 ns   3390354519 ns            1
    new    335514305 ns    335513720 ns            2
---
 be/src/util/uid_util.cpp | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/be/src/util/uid_util.cpp b/be/src/util/uid_util.cpp
index 6743c05a842..0f93f437ab6 100644
--- a/be/src/util/uid_util.cpp
+++ b/be/src/util/uid_util.cpp
@@ -17,6 +17,7 @@
 
 #include "util/uid_util.h"
 
+#include <fmt/compile.h>
 #include <gen_cpp/Types_types.h>
 #include <gen_cpp/types.pb.h>
 #include <glog/logging.h>
@@ -44,15 +45,13 @@ std::ostream& operator<<(std::ostream& os, const UniqueId& 
uid) {
 }
 
 std::string print_id(const TUniqueId& id) {
-    std::stringstream out;
-    out << std::hex << id.hi << "-" << id.lo;
-    return out.str();
+    return fmt::format(FMT_COMPILE("{:x}-{:x}"), static_cast<uint64_t>(id.hi),
+                       static_cast<uint64_t>(id.lo));
 }
 
 std::string print_id(const PUniqueId& id) {
-    std::stringstream out;
-    out << std::hex << id.hi() << "-" << id.lo();
-    return out.str();
+    return fmt::format(FMT_COMPILE("{:x}-{:x}"), 
static_cast<uint64_t>(id.hi()),
+                       static_cast<uint64_t>(id.lo()));
 }
 
 bool parse_id(const std::string& s, TUniqueId* id) {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to