-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[lldb-dap] Add timestamps to protocol logs #93540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I've found them very useful as a rudimentary form of benchmark.
@llvm/pr-subscribers-lldb Author: Pavel Labath (labath) ChangesI've found them very useful as a rudimentary form of benchmark. Full diff: https://github.com/llvm/llvm-project/pull/93540.diff 1 Files Affected:
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index c7eb3db4304a9..d419f821999e6 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -103,7 +103,9 @@ void DAP::SendJSON(const llvm::json::Value &json) {
SendJSON(json_str);
if (log) {
- *log << "<-- " << std::endl
+ auto now = std::chrono::duration<double>(
+ std::chrono::system_clock::now().time_since_epoch());
+ *log << llvm::formatv("{0:f9} <-- ", now.count()).str() << std::endl
<< "Content-Length: " << json_str.size() << "\r\n\r\n"
<< llvm::formatv("{0:2}", json).str() << std::endl;
}
@@ -130,9 +132,12 @@ std::string DAP::ReadJSON() {
if (!input.read_full(log.get(), length, json_str))
return json_str;
- if (log)
- *log << "--> " << std::endl << "Content-Length: " << length << "\r\n\r\n";
-
+ if (log) {
+ auto now = std::chrono::duration<double>(
+ std::chrono::system_clock::now().time_since_epoch());
+ *log << llvm::formatv("{0:f9} --> ", now.count()).str() << std::endl
+ << "Content-Length: " << length << "\r\n\r\n";
+ }
return json_str;
}
|
@@ -103,7 +103,9 @@ void DAP::SendJSON(const llvm::json::Value &json) { | |||
SendJSON(json_str); | |||
|
|||
if (log) { | |||
*log << "<-- " << std::endl | |||
auto now = std::chrono::duration<double>( | |||
std::chrono::system_clock::now().time_since_epoch()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wouldn't it be better to use steady_clock? that's more stable for benchmarking
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for a benchmark yes, but this is only a "benchmark" (with very large quotes). Like, I won't be using this during daylight savings switchover, and I don't think it's suitable for anything automated. And it's kinda nice it matches the time stamps for regular lldb logs (I literally copied this code from there).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good then!
I've found them very useful as a rudimentary form of benchmark.
I've found them very useful as a rudimentary form of benchmark.