Skip to content
Kuda Hitam edited this page Nov 19, 2023 · 1 revision

Usage

This page provides instructions on how to use the iCanLoadJS Performance Testing Module for conducting performance tests on HTTP endpoints.

Basic Usage

To perform a basic performance test using iCanLoadJS, follow these steps:

  • Import the icanloadjs module into your Node.js script:
const icanloadjs = require('icanloadjs');
  • Define the parameters for your performance test, such as the URL, HTTP method, number of requests, number of virtual users, data payload (if applicable), and any thresholds:
const url = 'https://example.com/api';
const method = 'GET';
const numRequests = 100;
const numVirtualUsers = 5;
const data = { key: 'value' };
const thresholds = {
  maxFailedChecks: 5,
  // Add more thresholds as needed
};
  • Run the performance test using the runIcan function:
icanloadjs.runIcan(url, method, numRequests, numVirtualUsers, data, thresholds);
  • View the metrics and results in the console output. The module provides various metrics, including the total number of requests, minimum and maximum response times, average response time, and more.

Customized Usage

You can customize your performance test by adjusting the parameters and thresholds based on your specific testing requirements. For example:

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

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

Next Steps

Explore the Metrics section to understand the metrics provided by the module. Additionally, you may want to set Thresholds to validate the success of your performance test.

Clone this wiki locally