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 🙏

© 2024 – Pkg Stats / Ryan Hefner

ts-performance-analyzer

v1.0.15

Published

a tool designed to help developers understand and optimize the performance of their TypeScript projects.

Downloads

108

Readme

TypeScript Performance Analyzer

TypeScript License

Overview

The TypeScript Performance Analyzer is a package designed to help developers understand and optimize the performance of their TypeScript projects. It provides insights into the number of files, lines, and types in a project, and measures the time taken for type-checking. The tool also offers suggestions for improving performance, making it an invaluable resource for large-scale TypeScript applications.

Features

  • Analyze the performance of TypeScript type-checking
  • Generate reports with details on the total number of files, lines, and types
  • Provide suggestions for optimizing type-checking performance
  • Easy integration with existing TypeScript projects

Installation

Install via NPM:


npm i ts-performance-analyzer

Features

This will generate a performance report with details about your TypeScript project, including:

  • Total number of files
  • Total lines of code
  • Total types found
  • Time taken for type-checking
  • Performance improvement suggestions
  • Performance of a specific function in a file (Total Execution Time and Its Memory Occupation)

Usage

  1. Import the library in your code
import TypeScriptPerformanceAnalyzer from "ts-performance-analyzer";
  1. Instantiate the class and pass the parameter of the root directory of your project
const analyzer = new TypeScriptPerformanceAnalyzer("path_to_your_project");
  1. In your package.json, make sure to add

"type": "module",
	"scripts": {
		"start": "node --loader ts-node/esm <path_to_your_index_file>"
	},
  1. Choose either testing the performance of the overall project or a specific function in a file

Testing overall performance of the project


const report = analyzer.analyze();

console.log("Performance Report:");
console.log(`Total Files: ${report.totalFiles}`);
console.log(`Total Lines: ${report.totalLines}`);
console.log(`Total Types: ${report.totalTypes}`);
console.log(`Type Checking Time: ${report.typeCheckingTime}ms`);

Sample Output:


Performance Report:
Total Files: 155
Total Lines: 113949
Total Types: 3688
Type Checking Time: 350.0381ms

Testing execution time and memory usage of a specific function

Base conditions for function performance analyzer Accepted:

  • Default functions
  • Functions that are arrow functions
  • Functions that are asynchronous functions

Not Accepted:

  • Functions that are exported
  • Functions that are constructors
  • Functions that are static methods
  • Functions that are class methods
line.includes(`async function ${functionName}`) ||
line.includes(`const ${functionName} = async`) ||
line.includes(`const ${functionName} = `) ||
line.includes(`function ${functionName}`) ||
 const foo = async () => {
  	const result = await analyzer.functionPerformance(
		__dirname, -> root_dir
		"/tests/test.ts", -> path
		"bubble" -> function_name
	 );

		return {
   time: result.totalTime,
   space: result.totalSpace
  }
 }

 foo().then((res) => {
		console.log("Function Performance Report:");
		console.log(`Function Total Time Execution: ${res.totalTime}ms`);
		console.log(`Function Memory Space: ${res.totalSpace}`);
	})

Sample Output:

Function Performance Report:
Function Total Time Execution: 0.037699999999858846ms
Function Memory Space: 1.73 KB

Contributing

If you'd like to contribute to the project, please follow these steps:

  1. Fork the repository
  2. Create a new branch (git checkout -b feature/my-feature)
  3. Commit your changes (git commit -am 'Add new feature')
  4. Push to the branch (git push origin feature/my-feature)
  5. Create a new Pull Request

License

This project is licensed under the MIT License.

Author

Francis Tin-ao.