Coder Social home page Coder Social logo

siege.js's Introduction

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 benchmark a page that requires 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 benchmark multiple apps in a single script.

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

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

But for unknown reasons, after the first app is done, the second app will quit. You have two options,

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

More features and improved reporting

Siege is open to adding more features. In particular, help is sought for improving the reporting interface. Also, we have with304 options, but it is not implemented.

Everybody is welcome to send a pull request.

siege.js's People

Contributors

guileen avatar madeinjam avatar natestone avatar chrisann0295 avatar ethanjfobrien avatar vkarpov15 avatar nemtsov avatar

Watchers

James Cloos avatar Adrián Hidalgo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.