1.0.3 • Published 5 years ago

top-performance v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

top-performance

Intro

use top to measure a real-time performance of a function, may be overkill, but who cares

prerequisite

$ command -v top

What's New

{
  "1.0.3": minor changes
  "1.0.2": construct unpredictable segment, increase stability
  "1.0.1": clean up the funciton, increase performance
  "1.0.0": include last Top record, open for testing
  "0.4.0": fix some data missing for some linux machine.
  "0.3.0": filter \n,  stabilize performance on few occasions
  "0.2.0": change spawn to exec, test both darwin/linux environment
}

Usage

Let's just jump into it.

const { Top } = require("top-performance");
var top = new Top();

top.run(() => "Smelly cat").then(data => console.log(data));

let darwin = {
  date: [],
  Processes: [],
  "Load Avg": [],
  "CPU usage": [],
  SharedLibs: [],
  MemRegions: [],
  PhysMem: [],
  VM: [],
  Networks: [],
  Disks: [],
  PID: [],
  COMMAND: [],
  "%CPU": [],
  TIME: [],
  "#TH": [],
  "#WQ": [],
  "#PORTS": [],
  MEM: [],
  PURG: [],
  CMPRS: [],
  PGRP: [],
  PPID: [],
  STATE: [],
  BOOSTS: [],
  "%CPU_ME": [],
  "%CPU_OTHRS": [],
  UID: [],
  FAULTS: [],
  COW: [],
  MSGSENT: [],
  MSGRECV: [],
  SYSBSD: [],
  SYSMACH: [],
  CSW: [],
  PAGEINS: [],
  IDLEW: [],
  POWER: [],
  INSTRS: [],
  CYCLES: [],
  USER: [],
  "#MREGS": [],
  RPRVT: [],
  VPRVT: [],
  VSIZE: [],
  KPRVT: [],
  KSHRD: []
};

let other = {
  time: [],
  "load average": [],
  Tasks: [],
  "%Cpu(s)": [],
  "KiB Mem ": [],
  "KiB Swap": [],
  "MiB Mem ": [],
  "MiB Swap": [],
  PID: [],
  USER: [],
  PR: [],
  NI: [],
  VIRT: [],
  RES: [],
  SHR: [],
  S: [],
  "%CPU": [],
  "%MEM": [],
  "TIME+": [],
  COMMAND: []
};

api

constructor(topOption = "")

detailed option use $ man top (["-p" , "-pid" , "-b" , "-n" , "-l"] option already taken)

example: new Top("-O mem")

run(functions: Function, warmup = 3, parse = true, liveLog = false)

warmup: eliminate noise, run functions x times before the real test

parse: parse the final Top Result

liveLog: console.log Top's current result;

1.0.3

5 years ago

1.0.2

5 years ago

1.0.0

5 years ago

0.3.0

5 years ago

0.2.0

5 years ago