Skip to content
Kuda Hitam edited this page Nov 19, 2023 · 2 revisions

iCanLoadJS Performance Testing Module

Overview

The iCanLoadJS Performance Testing Module is a Node.js module designed for conducting performance tests on HTTP endpoints. It provides a flexible framework for running multiple virtual users, tracking various metrics, and validating against predefined thresholds.

Table of Contents

Installation

To install the iCanLoadJS Performance Testing Module, run the following command:

npm install icanloadjs

Usage

const icanloadjs = require('icanloadjs');

// Define your testing parameters
const url = 'https://example.com/api';
const method = 'GET';
const numRequests = 100;
const numVirtualUsers = 5;
const data = { key: 'value' };
const thresholds = {
  maxFailedChecks: 5,
};

// Run the performance test
icanloadjs.runIcan(url, method, numRequests, numVirtualUsers, data, thresholds);

Examples

Basic Example

const icanloadjs = require('icanloadjs');

const url = 'https://example.com/api';
const numRequests = 100;
const numVirtualUsers = 5;

icanloadjs.runIcan(url, 'GET', numRequests, numVirtualUsers);

Customized Example

const icanloadjs = require('icanloadjs');

const url = 'https://example.com/api';
const numRequests = 200;
const numVirtualUsers = 10;
const data = { key: 'value' };
const thresholds = {
  maxFailedChecks: 10,
  // Add more thresholds as needed
};

icanloadjs.runIcan(url, 'POST', numRequests, numVirtualUsers, data, thresholds);

Metrics

The module provides various metrics to assess the performance of your API:

  • counter: Total number of requests made.
  • totalRequests: Total number of requests made by all virtual users.
  • minValue: Minimum response time recorded.
  • maxValue: Maximum response time recorded.
  • nonZeroCount: Number of non-zero response times.
  • sum: Sum of all response times.
  • averageValue: Average response time.
  • modeValue: Mode of response times.
  • percentileValue: Response time at the 50th percentile.
  • socketWaitTime: Total time spent waiting for a socket to be allocated.
  • checksPassed: Number of successful checks.
  • checksFailed: Number of failed checks.

Thresholds

Define thresholds to validate the success of the performance test:

  • maxFailedChecks: Maximum allowed failed checks. If exceeded, the test will be considered failed.

Clone this wiki locally