perf logging for crypto rpc

This commit is contained in:
Florian Dold 2016-11-16 02:10:12 +01:00
parent bd65bb67e2
commit af11f34fb5

View File

@ -187,8 +187,9 @@ export class CryptoApi {
private doRpc<T>(operation: string, priority: number, private doRpc<T>(operation: string, priority: number,
...args: any[]): Promise<T> { ...args: any[]): Promise<T> {
let start = performance.now();
return new Promise((resolve, reject) => { let p = new Promise((resolve, reject) => {
let rpcId = this.nextRpcId++; let rpcId = this.nextRpcId++;
let workItem: WorkItem = {operation, args, resolve, reject, rpcId}; let workItem: WorkItem = {operation, args, resolve, reject, rpcId};
@ -213,6 +214,11 @@ export class CryptoApi {
throw Error("assertion failed"); throw Error("assertion failed");
}); });
return p.then((r) => {
console.log(`rpc ${operation} took ${performance.now() - start}ms`);
return r;
});
} }