# Performance

# preloadWebview

Supported since Base Library 3.5.5

Preloads the WebView for the next page.

Parameters

Object object

Property Type Default Value Required Description
success function No Callback function for successful API call
fail function No Callback function for failed API call
complete function No Callback function for API call completion (executes regardless of success or failure)

# getPerformance

Supported since Base Library 3.5.5, SDK version 2.46.9

Retrieves performance-related information for the current Mini-Program.

Parameters

None

Return Value

Performance

Sample Code

const performance = ft.getPerformance()
const observer = performance.createObserver((entryList) => {
  console.log(entryList.getEntries())
})
observer.observe({ entryTypes: ['render', 'script'] })

# Performance

The Performance object provides performance monitoring capabilities for the current Mini-Program, obtained via ft.getPerformance().

# Performance.getEntries()

Retrieves all performance data currently in the buffer.

Return Value

PerformanceEntry

Returns all performance data.

# Performance.getEntriesByName(name, entryType)

Retrieves all performance data in the current buffer with the specified name and entry type.

Parameters

Parameter Type Required Description
name string Yes Specified name
entryType string No Specified type

Return Value

PerformanceEntry

Returns data matching the filter parameters.

# Performance.getEntriesByType(entryType)

Retrieves all performance data in the current buffer with the specified entry type.

Parameters

Parameter Type Required Description
entryType string Yes Specified type

Return Value

PerformanceEntry

Returns an array of performance data matching the criteria.

# Performance.setBufferSize(size)

Sets the buffer size. The default buffer holds 30 performance data entries.

Parameters

Parameter Type Required Description
size number Yes Buffer size

# Performance.createObserver(callback)

Creates a global performance event listener.

Parameters

Parameter Type Required Description
callback function Yes Callback function

Return Value

PerformanceObserver

# PerformanceObserver

Performance observation object returned by the Performance.createObserver method.

# PerformanceObserver.disconnect()

Stops listening.

# PerformanceObserver.observe(options)

Starts listening.

Parameters

Parameter Type Required Description
options Object Yes Observation configuration

Structure of options

Property Type Required Description
type string No Metric type, cannot be used simultaneously with entryTypes
entryTypes string[] No Metric types, cannot be used simultaneously with type

Valid Type Values

Type Description Notes
navigation Routing
render Rendering
script Script
loadPackage Code Package Download Not Supported

Callback Function Parameter

EntryList

Sample Code

const observer = ft.getPerformance().createObserver((entries) => {
  console.log(entries)
})

observer.observe({ entryTypes: ['render', 'script'] })

# EntryList

The EntryList object provides a set of methods to retrieve performance data entries.

# EntryList.getEntries()

Retrieves all performance data in the current list.

Return Value

PerformanceEntry

Returns all performance data in the current list.

# EntryList.getEntriesByName(name, entryType)

Retrieves all performance data in the current list with the specified name and entry type.

Parameters

Parameter Type Required Description
name string Yes Specified name
entryType string No Specified type

Return Value

PerformanceEntry

Returns performance data matching the filter criteria.

# EntryList.getEntriesByType(entryType)

Retrieves all performance data in the current list with the specified entry type.

Parameters

Parameter Type Required Description
entryType string Yes Specified type

Return Value

PerformanceEntry

Returns performance data matching the filter criteria.

Sample Code

const performance = ft.getPerformance()
const observer = performance.createObserver((entryList) => {
  console.log(entryList.getEntries())
  console.log(entryList.getEntriesByName('firstRender'))
  console.log(entryList.getEntriesByType('render'))
})
observer.observe({ entryTypes: ['render', 'script'] })

# PerformanceEntry

The PerformanceEntry object represents data for a single performance metric.

Properties

Property Type Description
name string Name of the performance metric
entryType string Type of the performance metric
startTime number Start time of the performance metric
duration number Duration of the performance metric, included only for some metrics
path string Included only for routing type metrics
pageId string Included only for routing type metrics

Sample Code

const performance = ft.getPerformance()
const observer = performance.createObserver((entryList) => {
  entryList.getEntries().forEach((entry) => {
    console.log('Name: ' + entry.name)
    console.log('Type: ' + entry.entryType)
    console.log('Start time: ' + entry.startTime)
    console.log('Duration: ' + entry.duration)
  })
})
observer.observe({ entryTypes: ['render', 'script'] })
© FinClip with ❤ , Since 2017