All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.lazerycode.jmeter.analyzer.parser.StatusCodes Maven / Gradle / Ivy

Go to download

Parses JMeter result files and computes performance indicators such as average request duration

There is a newer version: 1.0.6
Show newest version
package com.lazerycode.jmeter.analyzer.parser;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

/**
 * Counts http response status codes
 *
 * @author Arne Franken, Peter Kaul
 */
public class StatusCodes {

  /**
   * Http status code that is the first error status
   */
  public static final int HTTPCODE_ERROR = 400;

  /**
   * pseudo http error code that represents a TCP connection error
   */
  public static final int HTTPCODE_CONNECTIONERROR = 599;

  private final Map statusCodes = new HashMap();

  /**
   * Register statusCode or increment if statusCode is already registered
   *
   * @param code the statusCode
   */
  public void increment(int code) {

    Long result = statusCodes.get(code);
    if( result == null ) {
      statusCodes.put(code, 1L);
    }
    else {
      statusCodes.put(code, result+1);
    }
  }

  /**
   * @return a mapping from statusCode to count
   */
  public Map getCodes() {
    return Collections.unmodifiableMap(statusCodes);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy