Skip to content
This repository has been archived by the owner on Nov 22, 2024. It is now read-only.

Commit

Permalink
Flipper Network Plugin change timestamps source
Browse files Browse the repository at this point in the history
Summary:
Flipper Network plugin uses timestamps for various usages e.g. start time of network requests, request duration, etc.

This diff changes the origin of such timestamps.

[NSDate timeIntervalSinceReferenceDate] in favour of FBMonotonicDeviceTimeGetCurrentMilliseconds().

The former uses a timestamp based on date. The latter uses the system boot time.

This translates in errors when the Flipper Desktop app tries to make sense of such timestamps.

This change also adds parity with the Android network plugin that uses System.currentTimeMillis().

The result is multiplied by 1000 as JavaScript expects a timestamp in millseconds.

Reviewed By: fabiomassimo

Differential Revision: D29029192

fbshipit-source-id: b38a4798ecf1564f5801ff3549ffeb9671fa32d6
  • Loading branch information
lblasa authored and facebook-github-bot committed Jun 11, 2021
1 parent 33d5d00 commit 1cf7456
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

@interface NSDate (SonarUtility)

+ (uint64_t)timestamp;
+ (NSTimeInterval)timestamp;

@end

@interface FLEXUtility : NSObject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,9 @@ + (NSNumber*)random {

@implementation NSDate (SonarUtility)

+ (uint64_t)getTimeNanoseconds {
static struct mach_timebase_info tb_info = {0};
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
__unused int ret = mach_timebase_info(&tb_info);
assert(0 == ret);
});

return (mach_absolute_time() * tb_info.numer) / tb_info.denom;
}

+ (uint64_t)timestamp {
const uint64_t nowNanoSeconds = [self getTimeNanoseconds];
return nowNanoSeconds / 1000000;
+ (NSTimeInterval)timestamp {
const NSTimeInterval timestamp = [[NSDate date] timeIntervalSince1970];
return timestamp * 1000;
}

@end

0 comments on commit 1cf7456

Please sign in to comment.