You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

p-profiler

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

p-profiler

Run a promise (perhaps with p-queue) generating a profiler json suitable to be consumed inside Chrome or Edge devtools to be analyzed


Version published
Maintainers
1
Created

Changelog

Source

0.2.1

Mon, 19 Oct 2020 21:15:46 GMT

Patches

  • make sure typing allows either prefix / customOutputPath (kchau@microsoft.com)

Readme

Source

p-profiler

Run a promise (perhaps with p-queue) generating a profiler json suitable to be consumed inside Chrome or Edge devtools to be analyzed

Install

$ npm install p-profiler

Usage

The p-profiler library is a class. Simply instantiate a Profiler class to be used to run the task functions (functions that generate a Promise). This example uses p-graph to demonstrate how to use this library. The task functions in this example is wrapped inside a profiler and a promise queue to control concurrency

import Profiler from "p-profiler";
import pGraph from "p-graph";
import PQueue from "p-queue";

const concurrency = 3;

// Create a profiler with the same concurrency as the p-graph
const profiler = new Profiler({ concurrency });
const queue = new PQueue({ concurrency });

const putOnShirt = () =>
  queue.add(profiler.run(() => Promise.resolve("put on your shirt")));
const putOnShorts = () =>
  queue.add(profiler.run(() => Promise.resolve("put on your shorts")));
const putOnJacket = () =>
  queue.add(profiler.run(() => Promise.resolve("put on your jacket")));
const putOnShoes = () =>
  queue.add(profiler.run(() => Promise.resolve("put on your shoes")));
const tieShoes = () =>
  queue.add(profiler.run(() => Promise.resolve("tie your shoes")));

const graph = [
  [putOnShoes, tieShoes],
  [putOnShirt, putOnJacket],
  [putOnShorts, putOnJacket],
  [putOnShorts, putOnShoes],
];

await pGraph(graph).run(); // returns a promise that will resolve when all the tasks are done from this graph in order

// This writes out a
profiler.output();

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

FAQs

Package last updated on 19 Oct 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc