@@ -8,6 +8,10 @@ import type {Action} from "../action";
88
99export const packetType = "execution" ;
1010
11+ function nowMicros ( ) : bigint {
12+ return BigInt ( Math . floor ( ( performance . timeOrigin + performance . now ( ) ) * 1000 ) ) ;
13+ }
14+
1115function buildParams ( execution : ActionExecutionRequest , func : RuntimeFunctionProps ) : ( PlainValue | undefined ) [ ] {
1216 return ( func . parameters || [ ] ) . map ( param => {
1317 const field = execution . parameters ?. fields ?. [ param . runtimeName ] ;
@@ -38,13 +42,13 @@ export function handle(action: Action, execution: ActionExecutionRequest): void
3842 matchedConfig : conf ,
3943 } ;
4044
41- const startedAt = BigInt ( Date . now ( ) ) ;
45+ const startedAt = nowMicros ( ) ;
4246 const funcHandler = func . handler ;
4347 const allParams : ( PlainValue | undefined ) [ ] =
4448 funcHandler . length === params . length + 1 ? [ context as PlainValue , ...params ] : params ;
4549
4650 Promise . resolve ( funcHandler ( ...allParams ) ) . then ( ( value : PlainValue ) => {
47- const finishedAt = BigInt ( Date . now ( ) ) ;
51+ const finishedAt = nowMicros ( ) ;
4852 action . stream ! . requests . send ( ActionTransferRequest . create ( {
4953 data : {
5054 oneofKind : "result" ,
@@ -62,7 +66,7 @@ export function handle(action: Action, execution: ActionExecutionRequest): void
6266 } ) ) . catch ( err => console . error ( "Failed to send execution result:" , err ) ) ;
6367
6468 } ) . catch ( ( error : unknown ) => {
65- const finishedAt = BigInt ( Date . now ( ) ) ;
69+ const finishedAt = nowMicros ( ) ;
6670 const isRuntimeError = error instanceof RuntimeError ;
6771 action . stream ! . requests . send ( ActionTransferRequest . create ( {
6872 data : {
0 commit comments