Usage
Examples
Arguments
JavaScript file to profile
Custom title for the profile report (defaults to filename)
How It Works
The profiler:- Instruments code: Injects profiling hooks around function calls
- Executes: Runs your code while collecting timing data
- Processes: Analyzes performance metrics and builds visualizations
- Uploads: Sends data to profile.porffor.dev
- Displays URL: Provides link to interactive web report
Output
Profile Report
The generated URL opens an interactive web page with:Flame Graph
Visualizes the call stack and time spent in each function:- Width: Time spent in function (wider = more time)
- Height: Call stack depth
- Color: Differentiates between functions
- Interactive: Click to zoom, hover for details
Bar Chart
Shows top 50 functions by total time:- Total time spent
- Average time per call
- Minimum time
- Maximum time
- Call count
Metadata
Profile information:- Porffor version
- Runtime environment (Node.js version, browser)
- Execution date/time
- Total duration
- Sample count
Profiling Options
Optimization level affects profile results
Enable TypeScript parsing
Sample Filtering
The profiler filters very short samples:- Threshold: 0.01ms (configurable in source)
- Reason: Reduce noise and improve visualization clarity
- Impact: Ultra-fast function calls may not appear in flame graph but are counted in statistics
Understanding Results
Flame Graph Patterns
Wide bars
Wide bars
Functions taking significant time - optimization candidates
Deep stacks
Deep stacks
Many nested function calls - potential recursion or deep call chains
Multiple children
Multiple children
Function calling many sub-functions - coordination overhead
Flat stacks
Flat stacks
Most time in single function - optimize this function directly
Bar Chart Metrics
Cumulative time across all calls to this function
Mean time per function call
Fastest and slowest individual calls
Number of times function was called
Example Workflow
Analyze bottlenecks
- Identify hot functions in flame graph
- Check bar chart for most time-consuming functions
- Note call counts and average times
Progress Indicator
While running, the profiler shows a spinner with sample count:Internal Functions
Internal Porffor functions are marked differently in visualizations:- Compiler-generated functions
- Built-in functions
- Runtime helpers
Performance Impact
Profiling adds overhead:- Function call instrumentation
- Timing measurements
- Sample collection
Profile results show relative performance, not absolute runtime. Use for optimization guidance, not production benchmarking.
Optimization Tips
Based on profile results:Hot functions (wide flame bars)
Hot functions (wide flame bars)
- Optimize algorithm complexity
- Reduce redundant calculations
- Consider caching results
Many small calls (deep stacks)
Many small calls (deep stacks)
- Reduce function call overhead
- Inline small functions
- Batch operations
High call counts
High call counts
- Reduce loop iterations
- Combine multiple calls
- Use more efficient data structures
High max time variance
High max time variance
- Investigate worst-case inputs
- Optimize edge cases
- Add fast paths
Sharing Profiles
Profile URLs are public and shareable:Comparison Workflow
Limitations
- Only profiles function calls (not individual lines)
- Adds execution overhead
- Requires internet connection (uploads to profile.porffor.dev)
- Short-lived functions (less than 0.01ms) may be filtered
- Experimental feature, may have bugs
Privacy
Profile data includes:- Function names
- Timing information
- Call counts
- System information (Porffor version, runtime)
- Custom title
- Function source code
- Variable values
- Personal information
Advanced Usage
Troubleshooting
No samples collected
- Script may not have any function calls
- Execution too fast
- Try more complex code
Upload failed
- Check internet connection
- Verify profile.porffor.dev is accessible
- Try again later
Unexpected results
- Profile with different optimization levels
- Compare with manual timing using
console.time() - Report issues on GitHub
Next Steps
Optimize Code
Apply insights and re-run
Debug Issues
Interactive debugging
Compile Optimized
Build native binary with optimizations
Understanding Optimization
Learn about optimization flags