Skip to content

Commit

Permalink
Addressed following code review comments: (#80)
Browse files Browse the repository at this point in the history
1) Updated the performance README.md file with minor corrections.
	2) Removed 'DebugInfo' message from console output.
	3) Limited decimal places to 6 for metrics.
	4) Added a sample JSON config file to the repository for reference.
  • Loading branch information
JMkrish authored Apr 30, 2024
1 parent 24f49f6 commit 8648fa3
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 5 deletions.
8 changes: 5 additions & 3 deletions performance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Before using the script, ensure the following prerequisites are met:
## Usage

### 1. Configuration
A custom configuration file should be provided as a command-line argument. The script will use the parameters specified in that file for configuring the load test and fetching query data for the APIs under test.
A custom configuration file in JSON format should be provided as a command-line argument. The script will use the parameters specified in that file for configuring the load test and fetching query data for the APIs under test.

The configuration file should include the following parameters:

Expand All @@ -30,9 +30,11 @@ The configuration file should include the following parameters:

If any of these parameters are missing in the configuration file, the script raises an exception to ensure that crucial configuration parameters are provided.

Additionally, a sample configuration file named 'sample_configs.json' is provided in the repository.

### 2. Command Line Arguments
The script accepts two optional command-line arguments:
- `--config-file`: Path to the custom configuration file (default: None). If provided, the script will use the parameters specified in this file. If not provided, the script will use hardcoded default values for configuration parameters.
- `--config-file`: Path to the json configuration file. The script will use the parameters specified in this file. If not provided, the script will raise an error.
- `--metrics-xml`: Path to the XML file where performance metrics will be dumped (default: None). If provided, performance metrics will be saved to this file.


Expand All @@ -53,7 +55,7 @@ export ENV_SDK_VAR_API_SECRET="<Tenant API Secret>"
### 4. Running the Script
To run the script, execute the following command in your terminal:
```
python load_test_performance_analysis.py --config-file <path_to_config_file> --metrics-xml <path_to_xml_file>
python performance/load_test_performance_analysis.py --config-file <path_to_json_config_file> --metrics-xml <path_to_xml_file>
```
Replace `<path_to_xml_file>` with the desired path where you want to save the performance metrics XML file. If you don't want to save the metrics, you can omit the `--metrics-xml` argument.

Expand Down
9 changes: 7 additions & 2 deletions performance/load_test_performance_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,13 @@ def perform_test(
throughput = total_responses / elapsed_time if elapsed_time > 0 else 0
error_rate = (len(errors) / (len(response_times) + len(errors))) * 100

# Limiting the values to 6 decimal places
elapsed_time = round(elapsed_time, 6)
avg_response_time = round(avg_response_time, 6)
min_response_time = round(min_response_time, 6)
max_response_time = round(max_response_time, 6)
throughput = round(throughput, 6)

logger.info("Performance Metrics:")
logger.info(f"Run Time: {elapsed_time}")
logger.info(f"Number of Response: {total_responses}")
Expand Down Expand Up @@ -274,8 +281,6 @@ def perform_get_line_data_load_test(
"limit": line_data_config.get("MAX_ROWS", 100),
}

print(f"DebugInf:: query - {query}")

return perform_test(get_line_data, config, cli, **query)


Expand Down
70 changes: 70 additions & 0 deletions performance/sample_configs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"num_peak_users": 5,
"ramp_up_rate": 5,
"total_run_time": 10,
"min_wait_time": 1,
"max_wait_time": 5,
"get_cycles_query_config": {
"Machine": "Abidjan - Lasercut 1",
"End Time__gte": "2023-04-01T00:00:00",
"End Time__lte": "2023-04-02T00:00:00",
"_order_by": "-End Time",
"_limit": 100,
"_only": [
"Machine",
"Cycle Start Time",
"Cycle End Time",
"Production Day",
"Cycle Time (Net)",
"Cycle Time (Gross)",
"Shift",
"Output"
]
},
"get_line_data_query_config": {
"TIME_TYPE": "absolute",
"START_DATETIME": "2023-04-01T08:00:00.000Z",
"END_DATETIME": "2023-04-02T23:00:00.000Z",
"TIME_ZONE": "America/Los_Angeles",
"ASSETS": [
"JB_NG_PickAndPlace_1_Stage4"
],
"FIELDS": [
"stats__BLOCKED__val",
"stats__PneumaticPressure__val"
],
"FILTERS": [
{
"asset": "JB_NG_PickAndPlace_1_Stage4",
"field": "stats__PneumaticPressure__val",
"op": "gte",
"value": 75.25
}
],
"MAX_ROWS": 50
},
"get_kpi_data_viz_query_config": {
"TIME_TYPE": "relative",
"RELATIVE_START": 7,
"RELATIVE_UNIT": "day",
"TIME_ZONE": "America/Los_Angeles",
"ASSETS": [
"JB_NG_PickAndPlace_1_Stage4"
],
"KPIS": [
"quality"
],
"I_VARS": [
{
"name": "endtime",
"time_resolution": "day",
"query_tz": "America/Los_Angeles",
"output_tz": "America/Los_Angeles",
"bin_strategy": "user_defined2",
"bin_count": 50
}
],
"WHERE": [],
"DB_MODE": "sql"
}
}

0 comments on commit 8648fa3

Please sign in to comment.