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

siege

v0.2.0

Published

http benchmark by nodejs

Downloads

2,724

Readme

siege.js

sigetest

install

npm install siege --save

http benchmark

siege()
  .on(3000)
  .for(10000).times
  .get('/')
  .attack()

save as benchmark.js and run

node benchmark.js
  

Use siege start/stop service

siege(cmd) can start service before benchmark, stop service after benchmark, for agile development.

siege('node /path/to/app.js')
  .on(3000)
  .get('/')
  .attack()
  

You can also use siege('/path/to/app.js') to benchmark http handler of nodejs, require('app.js') must return a function(req, res).

siege(__dirname + '/app.js')
  .on(3000)
  .get('/')
  .attack()
  

Code above will start server listen at port 3000, benchmark module will connect to 3000. You can ignore .on(3000), default is .on('/tmp/siege.sock')

Server maybe need a little while to prepare, use .wait(ms) let benchmark wait a moment to do benchmark.

siege(__dirname + '/app.js')
  .wait(1000)
  .get('/')
  .attack()
  

Define task

Use method(url, params) to define task, you can define multiple tasks, this will help you figure out which page is slow on your site.

siege()
  .get('/')
  .post('/hello', {hello: 'world'})
  .attack()
  

Tasks will execute as define order one by one.

Repeat times and duration

Use .for(n).times define repeate times, use for(n).seconds define duration, you can use on siege for all tasks, or use it on single task.

siege()
  .for(10000).times
  .get('/').for(2).seconds
  .get('/about').for(3000).times
  .get('/contact')
  .attack()
  

Code above, / will do benchmark for 2 seconds, /about will do for 3000 times, /contact will do for 10000 times.

Concurrent

Use .concurrent(n) to control concurrent request. default is 15

siege()
  .concurrent(100)
  .get('/')
  .attack()

Cookie

Use .withCookie to enable cookie jar, so you can do benchmark on the page require login.

siege()
  .withCookie
  .post('/login', {user: pass}).for(1).times
  .get('/')
  .attack()

Start siege attack

Use .attack() to start siege attack.

Multiple app

In theory Siege can do benchmark on multiple app.

siege('app1.js')
  .get('/')
  .attack()
  
siege('app2.js')
  .get('/')
  .attack()
  

But under unknow reason, after first app done, seconde app will quit. You have two options,

  1. Don't use this feature
  2. send a pull request

More feature and report?

Siege will add new feature base on requirement, we have with304 options, but it is not implement.

Siege also want more beautiful report.

It's welcome to send a pull request.