Added measurment logs
This commit is contained in:
parent
a1b55ff65c
commit
c5e4de1619
1 changed files with 36 additions and 0 deletions
|
|
@ -85,6 +85,8 @@ const listenerForAddr = (addr, SEA) => async (order, orderID) => {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const listenerStartTime = Date.now()
|
||||||
|
|
||||||
ordersProcessed.add(orderID)
|
ordersProcessed.add(orderID)
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
|
|
@ -93,6 +95,8 @@ const listenerForAddr = (addr, SEA) => async (order, orderID) => {
|
||||||
)} -- addr: ${addr}`
|
)} -- addr: ${addr}`
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const orderAnswerStartTime = Date.now()
|
||||||
|
|
||||||
const alreadyAnswered = await getUser()
|
const alreadyAnswered = await getUser()
|
||||||
.get(Key.ORDER_TO_RESPONSE)
|
.get(Key.ORDER_TO_RESPONSE)
|
||||||
.get(orderID)
|
.get(orderID)
|
||||||
|
|
@ -103,6 +107,12 @@ const listenerForAddr = (addr, SEA) => async (order, orderID) => {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const orderAnswerEndTime = Date.now() - orderAnswerStartTime
|
||||||
|
|
||||||
|
logger.info(`[PERF] Order Already Answered: ${orderAnswerEndTime}ms`)
|
||||||
|
|
||||||
|
const decryptStartTime = Date.now()
|
||||||
|
|
||||||
const senderEpub = await Utils.pubToEpub(order.from)
|
const senderEpub = await Utils.pubToEpub(order.from)
|
||||||
const secret = await SEA.secret(senderEpub, getUser()._.sea)
|
const secret = await SEA.secret(senderEpub, getUser()._.sea)
|
||||||
|
|
||||||
|
|
@ -111,6 +121,10 @@ const listenerForAddr = (addr, SEA) => async (order, orderID) => {
|
||||||
SEA.decrypt(order.memo, secret)
|
SEA.decrypt(order.memo, secret)
|
||||||
])
|
])
|
||||||
|
|
||||||
|
const decryptEndTime = Date.now() - decryptStartTime
|
||||||
|
|
||||||
|
logger.info(`[PERF] Decrypt invoice info: ${decryptEndTime}ms`)
|
||||||
|
|
||||||
const amount = Number(decryptedAmount)
|
const amount = Number(decryptedAmount)
|
||||||
|
|
||||||
if (!isNumber(amount)) {
|
if (!isNumber(amount)) {
|
||||||
|
|
@ -142,17 +156,29 @@ const listenerForAddr = (addr, SEA) => async (order, orderID) => {
|
||||||
`onOrders() -> Will now create an invoice : ${JSON.stringify(invoiceReq)}`
|
`onOrders() -> Will now create an invoice : ${JSON.stringify(invoiceReq)}`
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const invoiceStartTime = Date.now()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
const invoice = await _addInvoice(invoiceReq)
|
const invoice = await _addInvoice(invoiceReq)
|
||||||
|
|
||||||
|
const invoiceEndTime = Date.now() - invoiceStartTime
|
||||||
|
|
||||||
|
logger.info(`[PERF] LND Invoice created in ${invoiceEndTime}ms`)
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
'onOrders() -> Successfully created the invoice, will now encrypt it'
|
'onOrders() -> Successfully created the invoice, will now encrypt it'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const invoiceEncryptStartTime = Date.now()
|
||||||
|
|
||||||
const encInvoice = await SEA.encrypt(invoice, secret)
|
const encInvoice = await SEA.encrypt(invoice, secret)
|
||||||
|
|
||||||
|
const invoiceEncryptEndTime = Date.now() - invoiceEncryptStartTime
|
||||||
|
|
||||||
|
logger.info(`[PERF] Invoice encrypted in ${invoiceEncryptEndTime}ms`)
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
`onOrders() -> Will now place the encrypted invoice in order to response usergraph: ${addr}`
|
`onOrders() -> Will now place the encrypted invoice in order to response usergraph: ${addr}`
|
||||||
)
|
)
|
||||||
|
|
@ -163,6 +189,8 @@ const listenerForAddr = (addr, SEA) => async (order, orderID) => {
|
||||||
type: 'invoice'
|
type: 'invoice'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const invoicePutStartTime = Date.now()
|
||||||
|
|
||||||
await new Promise((res, rej) => {
|
await new Promise((res, rej) => {
|
||||||
getUser()
|
getUser()
|
||||||
.get(Key.ORDER_TO_RESPONSE)
|
.get(Key.ORDER_TO_RESPONSE)
|
||||||
|
|
@ -179,6 +207,14 @@ const listenerForAddr = (addr, SEA) => async (order, orderID) => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const invoicePutEndTime = Date.now() - invoicePutStartTime
|
||||||
|
|
||||||
|
logger.info(`[PERF] Added invoice to GunDB in ${invoicePutEndTime}ms`)
|
||||||
|
|
||||||
|
const listenerEndTime = Date.now() - listenerStartTime
|
||||||
|
|
||||||
|
logger.info(`[PERF] Invoice generation completed in ${listenerEndTime}ms`)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error(
|
logger.error(
|
||||||
`error inside onOrders, orderAddr: ${addr}, orderID: ${orderID}, order: ${JSON.stringify(
|
`error inside onOrders, orderAddr: ${addr}, orderID: ${orderID}, order: ${JSON.stringify(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue