Giter VIP home page Giter VIP logo

perftrace's Introduction

perftrace

Record PerformanceEntry objects from Node.js and the Web in the Trace Event Format, so that it can be visualized on https://ui.perfetto.dev like this!

The code for this example is available here.

The code for this example is available here.

Check out the blog !

Install

To install via NPM, run:

npm i perftrace

Alternatively, you can use it in vanilla JS, without any bundler, by using a CDN or static hosting. For example, using ES Modules, you can import the library with:

<script type="module">
  import { TraceEvents } from "https://cdn.jsdelivr.net/npm/perftrace/index.mjs";
</script>

Usage

Check out the API documentation and the code examples.

License

This project is available under the MIT license. See LICENSE for the full license text.

perftrace's People

Contributors

raisinten avatar

Stargazers

Aurélien Boquet avatar Panagiotis Papadatis avatar Ash avatar Muhamad Assar avatar Momen avatar Amine Ben hammou avatar Alex Batalov avatar Trevor Norris avatar Jérémy avatar Eugene Klimov avatar Thomas.G avatar Rafał Więcek avatar Jacob Groß avatar nick-w-nick avatar Darren Whitlen avatar Leon Sorokin avatar Colin Diesh avatar Luke Fiji avatar Sven Sackers avatar Katsuyuki Karasawa avatar Jason Elliott avatar Tripp Donnelly avatar Phong Tran avatar Elves Vieira avatar Dylan Piercey avatar Stephan Renatus avatar Italo José avatar David Sanders avatar

Watchers

Leon Sorokin avatar  avatar

perftrace's Issues

Bug in representing interleaved events

The following code:

Repro
const { TraceEvents } = require("perftrace");

const { performance } = require("node:perf_hooks");
const { writeFileSync } = require("node:fs");

const traceEvents = new TraceEvents();

process.on("beforeExit", () => {
  const events = traceEvents.getEvents();
  traceEvents.destroy();
  writeFileSync("events.json", JSON.stringify(events));
});

performance.mark("A");
setTimeout(() => {
  performance.measure("A", "A");    // 2s [0s - 2s]
}, 2000);

performance.mark("B");
setTimeout(() => {
  performance.measure("B", "B");    // 1s [0s - 1s]
  performance.mark("C");
  setTimeout(() => {
    performance.measure("C", "C");  // 2s [1s - 3s]
  }, 2000);
}, 1000);

generates:
Screenshot 2024-04-25 at 13 21 04

but it should be:

0s    1s    2s    3s
|     |     |     |
|<----A---->|     |
|<-B->|<----C---->|

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.