@@ -20,6 +20,7 @@ import {logger} from '../../logger';
2020import * as utils from "../../utils" ;
2121
2222export const VERSION = 9 ;
23+ const PROFILE_TRANSACTIONS = false ;
2324
2425/**
2526 * Implementation of a CryptoStore which is backed by an existing
@@ -759,20 +760,26 @@ export class Backend {
759760 }
760761
761762 doTxn ( mode , stores , func , log = logger ) {
762- const txnId = this . _nextTxnId ++ ;
763- const startTime = Date . now ( ) ;
764- const description = `${ mode } crypto store transaction ${ txnId } in ${ stores } ` ;
765- log . debug ( `Starting ${ description } ` ) ;
763+ let startTime ;
764+ let description ;
765+ if ( PROFILE_TRANSACTIONS ) {
766+ const txnId = this . _nextTxnId ++ ;
767+ startTime = Date . now ( ) ;
768+ description = `${ mode } crypto store transaction ${ txnId } in ${ stores } ` ;
769+ log . debug ( `Starting ${ description } ` ) ;
770+ }
766771 const txn = this . _db . transaction ( stores , mode ) ;
767772 const promise = promiseifyTxn ( txn ) ;
768773 const result = func ( txn ) ;
769- promise . then ( ( ) => {
770- const elapsedTime = Date . now ( ) - startTime ;
771- log . debug ( `Finished ${ description } , took ${ elapsedTime } ms` ) ;
772- } , ( ) => {
773- const elapsedTime = Date . now ( ) - startTime ;
774- log . error ( `Failed ${ description } , took ${ elapsedTime } ms` ) ;
775- } ) ;
774+ if ( PROFILE_TRANSACTIONS ) {
775+ promise . then ( ( ) => {
776+ const elapsedTime = Date . now ( ) - startTime ;
777+ log . debug ( `Finished ${ description } , took ${ elapsedTime } ms` ) ;
778+ } , ( ) => {
779+ const elapsedTime = Date . now ( ) - startTime ;
780+ log . error ( `Failed ${ description } , took ${ elapsedTime } ms` ) ;
781+ } ) ;
782+ }
776783 return promise . then ( ( ) => {
777784 return result ;
778785 } ) ;
0 commit comments