npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

openclaw-performance-profiler

v1.0.0

Published

Performance profiling and cost optimization tool for OpenClaw workflows

Readme

📊 OpenClaw Performance Profiler

Optimize costs and performance for OpenClaw workflows - Track token usage, identify bottlenecks, and reduce API costs.

License Node Performance

🎯 Why This Matters

OpenClaw workflows can get expensive. This tool helps you:

  • 💰 Track Costs - Monitor API usage and expenses
  • ⚡ Find Bottlenecks - Identify slow operations
  • 🎯 Optimize Tokens - Reduce unnecessary token consumption
  • 📈 Visualize Metrics - Charts and reports
  • 🔔 Set Budgets - Alert when costs exceed thresholds

🚀 Quick Start

Install

npm install -g openclaw-performance-profiler

Profile a Workflow

openclaw-profile start
# ... run your workflow ...
openclaw-profile stop
openclaw-profile report

Example Output

📊 OpenClaw Performance Profile

⏱️  Execution Time: 12.3s
💰 Total Cost: $0.45
🎯 Token Usage: 15,234 tokens

📈 Breakdown by Tool:

Tool            Calls  Time     Tokens   Cost
─────────────────────────────────────────────
web_fetch         12   2.4s     1,200    $0.02
web_search         3   1.8s     4,500    $0.09
exec              45   0.8s       450    $0.01
message            5   0.2s     9,084    $0.33
─────────────────────────────────────────────
Total             65   5.2s    15,234    $0.45

🔍 Optimization Suggestions:

⚠️  web_fetch is called 12 times - consider batching
💡 message uses 60% of tokens - simplify prompts
✅ exec is well-optimized

📖 Commands

openclaw-profile start [name]

Start profiling a session:

openclaw-profile start my-workflow

# Options:
#  --watch          Live monitoring
#  --threshold <n>  Alert when cost > threshold

openclaw-profile stop

Stop current profiling session:

openclaw-profile stop

openclaw-profile report [session]

Generate performance report:

openclaw-profile report

# Options:
#  --format <json|html|csv>
#  --output <file>
#  --compare <session>  Compare with another session

openclaw-profile analyze [file]

Analyze execution logs:

openclaw-profile analyze openclaw.log

# Detects:
# - Redundant API calls
# - Token waste
# - Slow operations
# - Cost spikes

openclaw-profile budget set <amount>

Set cost budget:

openclaw-profile budget set 10.00  # $10/day

# Options:
#  --period <day|week|month>
#  --alert <email|slack|webhook>

📊 Metrics Tracked

Token Usage

  • Input tokens - Prompt/context sent to model
  • Output tokens - Model response
  • Total tokens - Sum of input + output
  • Cost - Based on model pricing

Performance

  • Execution time - Total duration
  • Tool latency - Individual tool call times
  • Queue time - Wait time for rate limits
  • Throughput - Operations per second

Resource Usage

  • API calls - Number of external requests
  • Retries - Failed attempts that retried
  • Cache hits/misses - If caching is enabled
  • Memory - Peak memory usage

🎓 Examples

Example 1: Compare Two Sessions

openclaw-profile report session-1 --compare session-2

Output:

Comparing: session-1 vs session-2

Metric              Session 1    Session 2    Δ
─────────────────────────────────────────────────
Execution Time      12.3s        8.7s         -29% ✅
Total Cost          $0.45        $0.32        -29% ✅
Token Usage         15,234       10,891       -28% ✅
API Calls           65           48           -26% ✅

🎉 session-2 is 29% cheaper and 29% faster!

Example 2: Identify Token Waste

openclaw-profile analyze --focus tokens

Output:

🎯 Token Usage Analysis

Top Token Consumers:
1. message → 9,084 tokens (60%)
   - Prompt is 3.2KB per call
   - 💡 Suggestion: Reduce context window

2. web_search → 4,500 tokens (30%)
   - Returns full web pages
   - 💡 Suggestion: Use extractMode: 'text'

3. web_fetch → 1,200 tokens (8%)
   - ✅ Optimal

Potential Savings: 40% reduction → $0.18 saved

Example 3: Real-Time Monitoring

openclaw-profile start --watch
📡 Live Performance Monitor

Time   Tool         Tokens   Cost      Status
────────────────────────────────────────────────
12:01  web_fetch      120    $0.002    ✅
12:01  message      1,850    $0.037    ✅
12:02  web_search   1,500    $0.030    ✅
12:02  message      1,920    $0.038    ⚠️ High tokens
12:03  exec            50    $0.001    ✅

Current Total: $0.108 | Budget: $10.00 | 1% used

🔧 Integration

As Middleware

import { Profiler } from 'openclaw-performance-profiler';

const profiler = new Profiler({
  enabled: true,
  logLevel: 'info',
});

// Wrap your workflow
profiler.wrap(async () => {
  await myWorkflow();
});

const report = profiler.getReport();
console.log(report);

Programmatic API

import { Profiler } from 'openclaw-performance-profiler';

const profiler = new Profiler();

profiler.startSession('my-workflow');

// Track individual operations
profiler.track('web_fetch', async () => {
  return await tools.web_fetch({ url: 'https://example.com' });
});

profiler.endSession();

// Get insights
const insights = profiler.analyze();
console.log(insights.suggestions);

📈 Visualization

Generate Charts

openclaw-profile chart --type line --metric cost --output cost-over-time.png

Chart types:

  • line - Trends over time
  • bar - Comparison between tools/sessions
  • pie - Proportion breakdown
  • heatmap - Time-based activity

Dashboard (Bonus Feature)

Run local web dashboard:

openclaw-profile dashboard --port 8080

Features:

  • Real-time metrics
  • Historical trends
  • Cost projections
  • Alerts management

🎯 Optimization Strategies

1. Reduce Token Usage

Before:

await tools.message({
  message: `Here is a very long explanation with lots of unnecessary words 
            that could be simplified and made more concise...` // 50 tokens
});

After:

await tools.message({
  message: `Concise explanation.` // 5 tokens
});
// Saved: 45 tokens × $0.002/token = $0.09

2. Batch API Calls

Before:

for (const url of urls) {
  await tools.web_fetch({ url });  // 10 separate calls
}

After:

await Promise.all(
  urls.map(url => tools.web_fetch({ url }))
);  // Parallel execution, 60% faster

3. Cache Results

Before:

// Fetch same data multiple times
const data1 = await tools.web_fetch({ url });
const data2 = await tools.web_fetch({ url });  // Duplicate!

After:

const cache = new Map();
const cached = cache.get(url) || await tools.web_fetch({ url });
cache.set(url, cached);
// Saved: 1 API call

4. Use Cheaper Models

Some tasks don't need the most powerful model:

// For simple classification
profiler.suggest('use-cheaper-model', {
  current: 'claude-sonnet-4',
  recommended: 'claude-haiku-3',
  savings: '80%',
});

💰 Cost Models (Built-in)

| Model | Input ($/1K tokens) | Output ($/1K tokens) | |-------|---------------------|----------------------| | Claude Sonnet 4 | $0.003 | $0.015 | | Claude Haiku 3 | $0.00025 | $0.00125 | | GPT-4 Turbo | $0.010 | $0.030 | | GPT-3.5 Turbo | $0.0005 | $0.0015 |

Prices are estimates. Configure actual pricing in config.

🤝 Contributing

Contributions welcome! Ideas:

  • [ ] More visualization types
  • [ ] Integration with billing APIs
  • [ ] ML-powered optimization suggestions
  • [ ] Slack/Discord notifications
  • [ ] Multi-tenant cost tracking

📄 License

MIT © Alex - Built for cost-effective OpenClaw

🔗 Links


Optimize performance. Reduce costs. Build smarter. 📊