Skip to content

Commit

Permalink
group by timer
Browse files Browse the repository at this point in the history
and again update version info
  • Loading branch information
besessener committed May 15, 2024
1 parent 1c6d493 commit 2615d2b
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 18 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ This HAR file now contains a detailed record of all network requests and respons

To install the JMeter HAR Importer plugin, follow these steps:

1. Download the latest release of the plugin JAR file from the [GitHub releases page](https://github.com/Qytera-Gmbh/JMeterHARImporterPlugin/releases).
2. Copy the downloaded JAR file to the "lib/ext" directory within your JMeter installation directory.
3. Restart JMeter to load the plugin.
1. In JMeter install the Plugins Manager
2. Choose the "HAR (HTTP Archive) Import" plugin

# Usage

Expand Down
2 changes: 1 addition & 1 deletion plugin.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Plugin metadata
name=JMeter HAR Importer Plugin
version=0.4.0
version=0.2.0
author=Matthias Eggert
description=This plugin allows importing HTTP Archive (HAR) files into JMeter.

Expand Down
8 changes: 4 additions & 4 deletions release-notes.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
Release Notes

Product Name: JMeter HAR Importer
Release Number: Version 0.4.0
Release Number: Version 0.2.0
Release Date: [2024-05-14]

Overview:
The JMeter HAR Importer plugin is designed to facilitate the import of HTTP Archive (HAR) files into JMeter. This release introduces essential features for importing HAR files and generating JMeter sampler elements based on the captured requests.
The JMeter HAR Importer plugin is designed to facilitate the import of HTTP Archive (HAR) files into JMeter. This release introduces option for en/disabling some options which were always active before.

Purpose:
This release note provides an overview of the purpose and features included in Version 0.4.0 of the JMeter HAR Importer plugin. It outlines the changes, bug fixes, and new features introduced in this release.
This release note provides an overview of the purpose and features included in Version 0.2.0 of the JMeter HAR Importer plugin. It outlines the changes, bug fixes, and new features introduced in this release.

Issue Summary:
- The importer has a host exclude list now
- Added multiple options for elements to be added or excluded.
- Groups http samplers into the same transaction controller, if they happen at the same time.
- Groups http samplers into the same transaction controller, if they were recorded at the same time.

Notes:
- For detailed instructions on installation and usage, refer to the plugin documentation.
Expand Down
Binary file modified screenshot-usage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 22 additions & 10 deletions src/main/java/de/qytera/jmeterharimporter/HARImporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
import java.net.URI;
import java.net.URL;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class HARImporter {
Expand Down Expand Up @@ -121,30 +123,40 @@ public JMeterTreeNode addNewThreadGroupWithSamplers(Boolean shouldAddThinkTime,
// Create a Thread Group to hold the requests
JMeterTreeNode threadGroupNode = addComponent(createThreadGroup(), root);

Map<Long, JMeterTreeNode> transactionControllers = new HashMap<>();
Map<Long, Boolean> transactionControllerHasTimer = new HashMap<>();

int i = 1;
long lastTimestamp = -1;
for (HarEntry harEntry : this.har.getLog().getEntries()) {
// calculate think time
if (lastTimestamp == -1) {
lastTimestamp = harEntry.getStartedDateTime().getTime(); // first entry should become 0
}

long currentEntryStartTime = harEntry.getStartedDateTime().getTime();
long timeDifference = currentEntryStartTime - lastTimestamp;

HarRequest harRequest = harEntry.getRequest();
URI uri = URI.create(harRequest.getUrl());
if (this.hostsIgnored.contains(uri.getHost())) {
continue;
}
// add a transaction controller for each entry to group the samplers
JMeterTreeNode transactionControllerNodeSub = addComponent(createTransactionController(
"TC.%03d - %s".formatted(i++, uri.getHost())),
threadGroupNode);

// calculate think time
if (lastTimestamp == -1) {
lastTimestamp = harEntry.getStartedDateTime().getTime(); // first entry should become 0
if (transactionControllers.get(timeDifference) == null) {
TransactionController transactionController = createTransactionController("TC.%03d - %s".formatted(i++, uri.getHost()));
JMeterTreeNode transactionControllerNodeSub = addComponent(transactionController, threadGroupNode);
transactionControllers.put(timeDifference, transactionControllerNodeSub);
}

long currentEntryStartTime = harEntry.getStartedDateTime().getTime();
long timeDifference = currentEntryStartTime - lastTimestamp;
JMeterTreeNode transactionControllerNodeSub = transactionControllers.get(timeDifference);

// add a constant timer to simulate the think time
if (shouldAddThinkTime) {
addComponent(createConstantTimer(timeDifference), transactionControllerNodeSub);
if (transactionControllerHasTimer.get(timeDifference) == null) {
transactionControllerHasTimer.put(timeDifference, true);
addComponent(createConstantTimer(timeDifference), transactionControllerNodeSub);
}
}

// add the http sampler
Expand Down

0 comments on commit 2615d2b

Please sign in to comment.