Giter Club home page Giter Club logo

android-performance's Introduction

android-performance

NPM version build status Test coverage node version npm download

Node.js wrapper to android performance with adb

Installment

$ npm i android-performance --save-dev

Usage

const perf = new AndroidPerformance();
const p1 = new Promise((resolve, reject) => {
  perf
    .initDevice()
    .then(() => perf.getMeminfoByPackageName(pkgName))
    .then(res => {
      resolve({
        item: 'Meminfo',
        data: res
      });
    });
});

const p2 = new Promise((resolve, reject) => {
  perf
    .initDevice()
    .then(() => perf.getPid(pkgName))
    .then(pid => {
      return perf
        .getThreadCountByPid(pid)
        .then(d => {
          resolve({
            item: 'ThreadCount',
            data: d
          });
        })
        .catch(e => {
          resolve(null);
        });
    })
    .catch(e => {
      resolve(null);
    });
});

const p3 = new Promise((resolve, reject) => {
  perf
    .initDevice()
    .then(() => perf.getPid(pkgName))
    .then(pid => {
      return perf
        .getUidByPid(pid)
        .then(uid => {
          return perf
            .getTrafficByUid(uid)
            .then(d => {
              resolve({
                item: 'Traffic',
                data: d
              });
            })
            .catch(e => {
              resolve(null);
            });
        })
        .catch(e => {
          resolve(null);
        });
    })
    .catch(e => {
      resolve(null);
    });
});

const p4 = new Promise((resolve, reject) => {
  perf
    .initDevice()
    .then(() => perf.getPid(pkgName))
    .then(pid => {
      return perf
        .getCPUByPid(pid)
        .then(d => {
          resolve({
            item: 'cpu',
            data: d
          });
        })
        .catch(e => {
          resolve(null);
        });
    });
});

Promise.all([p1, p2, p3, p4]).then(result => {
  console.log(`performance:${JSON.stringify(result)}`);
  done();
});

Contributors


xudafeng


supern


zhuyali

This project follows the git-contributor spec, auto updated at Sun Jul 18 2021 11:15:58 GMT+0800.

License

The MIT License (MIT)

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.