阿西河

所有教程

公众号
🌙
阿西河前端的公众号

我的收藏

    最近访问  (文章)

      教程列表

      抓包专区
      测试专区

      Node.js perf_hooks new PerformanceObserver

      Node.js perf_hooks new PerformanceObserver(callback)

      新增于: v8.5.0

      • callback < Function>
        • list
        • observer

      PerformanceObserver objects provide notifications when new PerformanceEntry instances have been added to the Performance Timeline.

      const {
        performance,
        PerformanceObserver
      } = require('perf_hooks');
      
      const obs = new PerformanceObserver((list, observer) => {
        console.log(list.getEntries());
        observer.disconnect();
      });
      obs.observe({ entryTypes: ['mark'], buffered: true });
      
      performance.mark('test');
      

      Because PerformanceObserver instances introduce their own additional performance overhead, instances should not be left subscribed to notifications indefinitely. Users should disconnect observers as soon as they are no longer needed.

      The callback is invoked when a PerformanceObserver is notified about new PerformanceEntry instances. The callback receives a PerformanceObserverEntryList instance and a reference to the PerformanceObserver.


      更多内容请参考:Node.js perf_hooks 性能钩子,或者通过 点击对应菜单 进行查看;


      目录
      本文目录
      目录