8.0.0 • Published 19 days ago

anys-web-plugin-monitor-performance v8.0.0

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
19 days ago

AnysMonitorPerformancePlugin

  1. web navigation performance
  2. anys-perf custom element to record first render time
  3. fps

Install

npm i anys-web-plugin-monitor-performance
<script src="https://unpkg.com/anys"></script>
<script src="https://unpkg.com/anys-web-plugin-monitor-performance"></script>
<script>
    const { Anys, AnysMonitorPerformancePlugin } = window.anys;
    const anys = new Anys({
        plugins: [AnysMonitorPerformancePlugin],
    });
</script>

Options

  • performance: boolean (true)
  • fps: boolean | number (true)
const anys = new Anys({
    plugins: [AnysMonitorPerformancePlugin],
    fps: 40, // when fps is lower than 40, anys will write a log
});

Log

performance

{
    type: 'performance.navigation',
    time: Date.now(),
    detail: {
        url,
        redirectCount,
        type,
        timeOrigin,

        startTime,
        unloadEventStart,
        unloadEventEnd,
        redirectStart,
        redirectEnd,
        workerStart,
        fetchStart,
        domainLookupStart,
        domainLookupEnd,
        connectStart,
        secureConnectionStart,
        connectEnd,
        requestStart,
        responseStart,
        responseEnd,
        domInteractive,
        domContentLoadedEventStart,
        domContentLoadedEventEnd,
        domComplete,
        loadEventStart,
        loadEventEnd,

        FP,
        FCP,
        TTFB,
        LCP,
        TTI,

        TCP,
        DNS,
        REQUEST,
        RESPONSE,
        REDIRECT,
        TLS,
        COMPRESSED,
        CACHED,
        PROTOCOL,
    },
}
{
    type: 'performance.measure',
    time: Date.now(),
    name,
    detail: {
        timeOrigin,
        startTime,
        duration,
    },
}
{
    type: 'performance.dom',
    time: Date.now(),
    name,
    data: {
        // dataset on DOM element
        ...
    },
    detail: {
        timeOrigin,
        startTime: domInteractive,
        duration: now - domInteractive,
    },
}

fps

{
    type: 'performance.fps',
    time: Date.now(),
    fps,
    detail: {
        timeOrigin,
        startTime: firstFrame,
        duration: now - firstFrame,
    },
}

API

anys-perf

Custom element for div tag, to monitor a div element's first render time.

<div is="anys-perf" data-name="my-monitor-node"></div>

Dataset:

  • name: the monitor point name (required)

Other dataset properties will be report at the same time.

mark(name)

Plugin method to create a mark and get the measure method.

const anys = new Anys({
    plugins: {
        performance: AnysMonitorPerformancePlugin,
    }
})
const measure = anys.plugins.performance.mark('my-monitor-point');
// ... do some thing
// support async tasks
measure(); // -> write a performance log and clear mark
8.0.0

19 days ago

7.0.0

2 months ago

6.4.0

5 months ago

6.3.0

5 months ago

6.2.0

5 months ago

6.1.1

6 months ago

6.0.0

6 months ago

5.0.3

6 months ago

5.0.2

7 months ago

5.0.0

7 months ago

4.0.0

7 months ago

3.1.0

8 months ago

3.0.3

8 months ago

3.0.2

8 months ago

3.0.1

8 months ago

3.0.0

8 months ago

2.0.2

8 months ago

2.0.0

8 months ago

1.4.0

8 months ago

1.2.0

9 months ago

1.1.3

9 months ago

1.1.0

9 months ago

1.0.1

9 months ago