Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

performance-profiler

npm install @ferrow/performance-profiler

CI

Instrumentation helpers over perf_hooks. Mark/measure, profile functions with memory delta, and hierarchical section timing with tree report.

Quickstart

import { PerformanceProfiler } from 'performance-profiler';

const profiler = new PerformanceProfiler();

// Section timing
profiler.start('main');
  profiler.start('io');
  // ... I/O work
  profiler.end();

  profiler.start('compute');
  // ... CPU work
  profiler.end();
profiler.end();

console.log(profiler.report());
// Performance Report
// ==================
// ├─ main               123.45ms (100.0%)
//   ├─ io                 50.23ms (40.7%)
//   ├─ compute            73.22ms (59.3%)

API

mark(name) / measure(name, startMark, endMark)

Create marks and measure duration between them.

profiler.mark('start');
// ... work
profiler.mark('end');
const ms = profiler.measure('task', 'start', 'end');

profile(fn) / profileAsync(fn)

Profile a function. Returns {result, durationMs, memoryDeltaBytes}.

const { result, durationMs, memoryDeltaBytes } = profiler.profile(() => heavyComputation());

const { result, durationMs, memoryDeltaBytes } = await profiler.profileAsync(async () => {
  return await fetchData();
});

start(name) / end()

Hierarchical section timing. Nesting creates tree structure.

profiler.start('parent');
  profiler.start('child1');
  // ... work
  profiler.end();
  
  profiler.start('child2');
  // ... work
  profiler.end();
profiler.end();

report()

Render tree with durations and percentages.

console.log(profiler.report());

reset()

Clear all sections and marks.

Scope & Limits

  • Hierarchical timing only — no flame graphs or detailed CPU analysis
  • Memory delta via process.memoryUsage() — heap-only; GC may skew results
  • perf_hooks.performance — browser-compatible interface
  • In-process only — no cross-process tracing
  • No overhead estimation — profiling has measurement overhead

License

MIT


Sponsored by Ferrow


Part of the ferrow-toolkit collection · Sponsored by Ferrow

About

Instrumentation helpers for perf_hooks with hierarchical section timing and memory tracking

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages