Giter VIP home page Giter VIP logo

memory-inspector's Introduction

memory-inspector

CircleCI

Memory Inspector watches memory usage/behavior of an Web Application. Currently it runs over Puppeteer, which is an API to control headless Chrome or Chromium over the DevTools Protocol.

Installing

yarn add --dev memory-inspector

Usage

Example 1

const memoryInspector = require('memory-inspector')

const config = {
  url: 'http://localhost:3000',
  maxMemoryLimit: 20 * 1048576, // should not pass of 20MB
  maxMemoryPercentThreshold: 90, // should not pass 90% of total memory
}

memoryInspector(config).then((info) => console.log(info))

/*
{ "exceededMemoryMaximum": 1528951424,
  "exceededMemoryUsagePercent": true,
  "jsHeapSizeLimit": "2.19 GB",
  "memoryUsagePercent": 21900000,
  "totalJSHeapSize": "1.53 GB",
  "usedJSHeapSize": "1.53 GB" }
*/

Example 2

const memoryInspector = require('memory-inspector')

const config = {
  url: 'http://127.0.0.1:8080',
  delay: 300,
  formatted: false, // default is true
  maxMemoryLimit: 20 * 1048576, // should not pass of 20MB
  maxMemoryPercentThreshold: 90, // should not pass 90% of total memory
  waitUntil: ['domContentLoaded'], // wait for browser events
}

memoryInspector(config).then((info) => console.log(info))

/*
{ usedJSHeapSize: 10000000,
  totalJSHeapSize: 11900000,
  jsHeapSizeLimit: 2190000000,
  memoryUsagePercent: 438000000,
  exceededMemoryMaximum: -10971520,
  exceededMemoryUsagePercent: false }
*/

Config

url

<string> URL to navigate page to. The url should include scheme, e.g. https://

formatted

<boolean> Define if will format bytes into sizes, like: 2190000000 to 2.19 GB. By default it's true.

delay

<number> Slows down report by the specified amount of milliseconds.

maxMemoryLimit

<number> Sets maximum memory limit which can be used by application, it will reflect on exceededMemoryMaximum report.

maxMemoryPercentThreshold

<number> Sets maximum memory percent threshold on application, it will reflect on exceededMemoryUsagePercent report.

waitUntil

<string|array<string>> When to consider navigation succeeded. Given an array of event strings, navigation is considered to be successful after all events have been fired.

Roadmap

  • Iterate report operations by configuration
  • Prediction report
  • Integrate with Jest
  • Write decent tests
  • Allows to specify executable based on Webkit Binaries

About

A Thanks to Puppeteer.

Made by Raphael Amorim, Licensed by MIT

memory-inspector's People

Contributors

diegohaz avatar raphamorim avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

memory-inspector's Issues

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.