How do you derive walltime from timestamp using Chrome's debugger protocol?

不打扰是莪最后的温柔 提交于 2020-06-16 04:26:25

问题


I've been building a Chrome extension using in part the Chrome debugger protocol. Certain events in the Network domain like requestWillBeSent include a "timestamp" as well as a "wallTime."

The walltime is a regular seconds since 1970 format, but the timestamp is in seconds but its not clear where its 0 is, and many events have no wallTime so I'm really trying to figure out how to derive wallTime from timeStamp. Based on this I believed to be based on the navigationStart value but that did not yield the correct date based on either the background page of the extension's navigationStart nor the page where the event originated navigationStart.

Is it possible at all to use timestamp to get at the wallTime or am I out of luck?


回答1:


According to source code in InspectorNetworkAgent.cpp:

  • wallTime is currentTime() (normal system time)
  • timestamp is monotonicallyIncreasingTime()

    On Windows it's based on the number of milliseconds that have elapsed since the system was started, and you can't get that info from an extension.

    On POSIX systems (e.g. Linux) clock_gettime in CLOCK_MONOTONIC mode is used that represents monotonic time since some unspecified starting point.

    According to source code in time.h:

    TimeTicks and ThreadTicks represent an abstract time that is most of the time incrementing, for use in measuring time durations. Internally, they are represented in microseconds. They can not be converted to a human-readable time, but are guaranteed not to decrease (unlike the Time class). Note that TimeTicks may "stand still" (e.g., if the computer is suspended), and ThreadTicks will "stand still" whenever the thread has been de-scheduled by the operating system.



来源:https://stackoverflow.com/questions/39627245/how-do-you-derive-walltime-from-timestamp-using-chromes-debugger-protocol

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!