提交 3bc94738 编写于 作者: M Megvii Engine Team

fix(profiler): do not assume clock duration and time_point type

GitOrigin-RevId: 2015bc30bdb54d2c3f0101d651dbe2b9ab72cc5d
上级 b7e6bd7b
......@@ -125,6 +125,7 @@ struct MemoryFlow {
}
XMLWriter to_svg() const {
using namespace std::chrono_literals;
XMLWriter writer;
auto&& [addr_begin, addr_end] = address_range();
auto&& [time_begin, time_end] = time_range();
......@@ -135,15 +136,15 @@ struct MemoryFlow {
auto svg = writer.element("svg");
svg.attr("xmlns", std::string{"http://www.w3.org/2000/svg"});
svg.attr("xmlns:tag", std::string{"https://megengine.org.cn"});
double time_scale = 1e5;
auto time_scale = 100us;
double addr_scale = 1e6;
svg.attr("width", (time_end-time_begin).count()/time_scale);
svg.attr("width", (time_end-time_begin)/time_scale);
svg.attr("height", (addr_end-addr_begin)/addr_scale);
{
auto rect = writer.element("rect");
rect.attr("x", 0);
rect.attr("y", 0);
rect.attr("width", (time_end-time_begin).count()/time_scale);
rect.attr("width", (time_end-time_begin)/time_scale);
rect.attr("height", (addr_end-addr_begin)/addr_scale);
rect.attr("fill", std::string{"blue"});
}
......@@ -198,8 +199,8 @@ struct MemoryFlow {
for (auto&& [id, chunk]: chunks) {
MGB_MARK_USED_VAR(id);
if (chunk.empty()) continue;
double left = (chunk.time[0]-time_begin).count()/time_scale;
double right = (chunk.time[1]-time_begin).count()/time_scale;
double left = (chunk.time[0]-time_begin)/time_scale;
double right = (chunk.time[1]-time_begin)/time_scale;
double top = (chunk.address[0]-addr_begin)/addr_scale;
double bottom = (chunk.address[1]-addr_begin)/addr_scale;
double duration = (chunk.time[1] - chunk.time[0]).count();
......
......@@ -34,11 +34,11 @@ namespace imperative {
namespace profiler {
using HostTime = std::chrono::time_point<std::chrono::system_clock>;
using HostTime = std::chrono::system_clock::time_point;
using Duration = std::chrono::nanoseconds;
using Duration = std::chrono::system_clock::duration;
using RealDuration = std::chrono::duration<double, std::nano>;
using RealDuration = std::chrono::duration<Duration::rep, Duration::period>;
using Time = HostTime;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册