Skip to content

Commit ef78aaf

Browse files
committed
debug: add log to calculate the time to get quotes
1 parent cf32d2d commit ef78aaf

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

apps/kyberswap-interface/src/pages/CrossChainSwap/hooks/useCrossChainSwap.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,10 @@ export const CrossChainSwapRegistryProvider = ({ children }: { children: React.R
609609
setLoading(true)
610610
setAllLoading(true)
611611

612+
// Track quote fetching time
613+
const quoteStartTime = performance.now()
614+
console.log('[Quote Timing] Starting to fetch quotes...')
615+
612616
const getQuotesWithCancellation = async (params: QuoteParams | NearQuoteParams) => {
613617
const quotes: Quote[] = []
614618

@@ -932,6 +936,18 @@ export const CrossChainSwapRegistryProvider = ({ children }: { children: React.R
932936
} finally {
933937
setLoading(false)
934938
setAllLoading(false)
939+
940+
// Log total time taken to fetch all quotes
941+
const quoteEndTime = performance.now()
942+
const totalTime = quoteEndTime - quoteStartTime
943+
const tokenInSymbol = (currencyIn as any)?.symbol || (currencyIn as any)?.wrapped?.symbol || 'Unknown'
944+
const tokenOutSymbol = (currencyOut as any)?.symbol || (currencyOut as any)?.wrapped?.symbol || 'Unknown'
945+
console.log(
946+
`[Quote Timing] All quotes fetched and processed. ${amount} ${tokenInSymbol} -> ${tokenOutSymbol}. Total time: ${totalTime.toFixed(
947+
2,
948+
)}ms (${(totalTime / 1000).toFixed(2)}s)`,
949+
)
950+
console.log(`[Quote Timing] Number of quotes received: ${quotes.length}`)
935951
}
936952
}, [
937953
sender,

0 commit comments

Comments
 (0)