Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 679
edibleEnergy Avatar asked Mar 12 '23 02:03

edibleEnergy


1 Answers

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.

like image 192
wOxxOm Avatar answered Apr 13 '23 00:04

wOxxOm