From cb3a07306e5ef86146270782faa90830cc72ae8c Mon Sep 17 00:00:00 2001 From: Tadeu Zagallo Date: Mon, 2 Nov 2015 08:13:42 -0800 Subject: [PATCH] Expose `RCTPerformanceNow`, microsecond precision time for JavaScript Summary: public Expose a more precise timer, millisecond precision is enough to measure small operations. Reviewed By: javache Differential Revision: D2604218 fb-gh-sync-id: ba50c891b5690575548fe04ba1ae7d015bc31d90 --- React/Executors/RCTContextExecutor.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/React/Executors/RCTContextExecutor.m b/React/Executors/RCTContextExecutor.m index c4315e8d5..429bb0f62 100644 --- a/React/Executors/RCTContextExecutor.m +++ b/React/Executors/RCTContextExecutor.m @@ -353,6 +353,10 @@ static void RCTInstallJSCProfiler(RCTBridge *bridge, JSContextRef context) [bridge handleBuffer:calls batchEnded:NO]; }; + strongSelf->_context.context[@"RCTPerformanceNow"] = ^(){ + return CACurrentMediaTime() * 1000 * 1000; + }; + #if RCT_DEV if (RCTProfileIsProfiling()) { strongSelf->_context.context[@"__RCTProfileIsProfiling"] = @YES;