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

amtal

v0.4.1

Published

To know a thing well, know its limits. Only when pushed beyond its tolerances will true nature be seen.

Downloads

16

Readme

Amtal

To know a thing well, know its limits. Only when pushed beyond its tolerances will true nature be seen. – The Amtal Rule

Simple load testing tool done out of sheer desperation to load test Sapho (Yes, we're Frank Herbert's Dune enthusiasts).

Aimed at easy scripting of real-world API usage

When use Amtal

If you want to write a complex test script of REST API simulating real service usage, are not afraid of little Javascript, if you want to run the script on your infrastructure and not pay a dime for the tool, Amtal is for you.

If you want to record web app usage and then just replay it, or smash a few resources as hard as you can with no logic involved, there are lot of tools out there, probably better suited for the task.

Basic Usage

let amtal = require('amtal');

let scenario = user =>
    Promise.resolve()
    // Sequential requests with tink time in between:
    .then(user.POST("Submit Login","/api/login", {user: "tom", "password": "123"})) // POST, PUT: request name, path, data [, options]
    .then(user.wait(2))
    .then(user.GET("Get Main Data", "/api/data"), {processResponse: true}) // GET: request name, path [, options]
    // Parallel requests
    .then(response => Promise.all(
        JSON.parse(response.body).links.map(link => 
            user.GET("Get " + link.name, link.url)())));

let configuration = {
    host: "api.acme.com"
};

let rampup = { 
    0: 0, // minute => number of running users
    '1:30': 5, // or 'h:m:s' => number of running users
    2: 5,
    5: 50,
    10: 50
}

amtal
    .run(scenario, configuration, rampup)
    .then(amtal.exportResults({dir:"results"}))

Promises Cookbook

  • Start with Proimise.resolve().
  • Chain synchronous requests with .then(user.METHOD(...)).then(user.METHOD(...)).
  • To process response syncronously, set the processResponse option to true and chain .then(data => new Promise((resolve, reject) => { /* work with data (raw response)*/; resolve(); }))
  • To fire parallel requests (and wait for all to complete), do .then(() => Promise.all([user.GET(...)(), user.POST(...)()])) - notice the METHOD functions are executed here! You're chaining a function returning a promise of array, not array of promises!
  • To add a result processing in the parallel part, instead of single user.GET(...)(), do Promise.resolve().then(user.METHOD(...)).then(data => new Promise((resolve, reject) => {})) - same as the top level promise chain

User Context

The user instance holds a context hash (user.context) that can be used to store values and use them in path interpolation.

To use the context values in path interpolation, use ${this.foo} in second (path) argument of user.METHOD shortcut methods. ${this.foo} will be resolved to value of user.context.foo when the request is initiated.