提交 60104628 编写于 作者: S siyangy 提交者: Jiangtao Hu

Dreamview: Meaure websocket write time

上级 68e77929
......@@ -244,8 +244,7 @@ class Clock {
inline Clock::Clock()
: Clock(FLAGS_use_ros_time ? ClockMode::ROS : ClockMode::SYSTEM) {}
// Measure run time of a code block, for debugging puprpose only, don't check in
// code with this macro!
// Measure run time of a code block, mostly for debugging puprpose.
// Example usage:
// PERF_BLOCK("Function Foo took: ") {
// Foo();
......@@ -260,19 +259,18 @@ inline Clock::Clock()
#define PERF_BLOCK_NO_THRESHOLD(message) PERF_BLOCK_WITH_THRESHOLD(message, 0)
#define PERF_BLOCK_WITH_THRESHOLD(message, threshold) \
using apollo::common::time::Clock; \
for (double block_start_time = 0; \
(block_start_time == 0 ? (block_start_time = Clock::NowInSecond()) \
: false); \
[block_start_time]() { \
double now = Clock::NowInSecond(); \
if (now - block_start_time > (threshold)) { \
ADEBUG << std::fixed << (message) << ": " \
<< now - block_start_time; \
} \
#define PERF_BLOCK_WITH_THRESHOLD(message, threshold) \
using apollo::common::time::Clock; \
for (double block_start_time = 0; \
(block_start_time == 0 ? (block_start_time = Clock::NowInSecond()) \
: false); \
[block_start_time]() { \
double now = Clock::NowInSecond(); \
if (now - block_start_time > (threshold)) { \
ADEBUG << std::fixed << (message) << ": " << now - block_start_time \
<< "s."; \
} \
}())
} // namespace time
} // namespace common
} // namespace apollo
......
......@@ -152,6 +152,7 @@ MapElementIds MapService::CollectMapElementIds(const PointENU &point,
if (sim_map_.GetSignals(point, radius, &signals) != 0) {
AERROR << "Failed to get signals from sim_map.";
}
ExtractIds(signals, &result.signal);
ExtractOverlapIds(signals, &result.overlap);
......
......@@ -12,6 +12,7 @@ cc_library(
],
deps = [
"//modules/common",
"//modules/common/time",
"//modules/common/util:string_util",
"//third_party/json",
"@civetweb//:civetweb++",
......
......@@ -20,6 +20,7 @@ limitations under the License.
#include "modules/common/log.h"
#include "modules/common/util/string_util.h"
#include "modules/common/time/time.h"
namespace apollo {
namespace dreamview {
......@@ -102,8 +103,11 @@ bool WebSocketHandler::SendData(const std::string &data, Connection *conn,
}
// Note that while we are holding the connection lock, the connection won't be
// closed and removed.
int ret = mg_websocket_write(conn, WEBSOCKET_OPCODE_TEXT, data.c_str(),
int ret;
PERF_BLOCK("Websocket write took too long", 0.5) {
ret = mg_websocket_write(conn, WEBSOCKET_OPCODE_TEXT, data.c_str(),
data.size());
}
connection_lock->unlock();
if (ret != static_cast<int>(data.size())) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册