-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new constant loader & Fix poisson loader issue (#158)
* Fix typo in benchmark.yaml Signed-off-by: CharleneHu-42 <[email protected]> * Add load shape related information into outputs. Signed-off-by: CharleneHu-42 <[email protected]> * add new constant loader & fix poisson loader issue Signed-off-by: CharleneHu-42 <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Signed-off-by: CharleneHu-42 <[email protected]> * fix typo Signed-off-by: CharleneHu-42 <[email protected]> * unset stop_timeout for locust workers to avoid exception Signed-off-by: CharleneHu-42 <[email protected]> * fix readme Signed-off-by: CharleneHu-42 <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Signed-off-by: CharleneHu-42 <[email protected]> Co-authored-by: Yi Yao <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: lvliang-intel <[email protected]>
- Loading branch information
1 parent
a807b8a
commit e11588c
Showing
6 changed files
with
91 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Copyright (C) 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import logging | ||
|
||
import locust | ||
from locust import LoadTestShape, events | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
@events.init_command_line_parser.add_listener | ||
def _(parser): | ||
parser.add_argument( | ||
"--arrival_rate", | ||
type=float, | ||
default=1.0, | ||
) | ||
|
||
|
||
class ConstantRPSLoadShape(LoadTestShape): | ||
use_common_options = True | ||
|
||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
self.arrival_rate = locust.argument_parser.parse_options().arrival_rate | ||
self.last_tick = 0 | ||
|
||
def tick(self): | ||
if self.last_tick == 0: | ||
logger.info("Constant load shape arrival rate: {arrival_rate}".format(arrival_rate=self.arrival_rate)) | ||
|
||
run_time = self.get_run_time() | ||
if run_time < self.runner.environment.parsed_options.run_time: | ||
self.last_tick = run_time | ||
|
||
new_users = int(self.arrival_rate) | ||
current_users = self.get_current_user_count() | ||
user_count = current_users + new_users | ||
logger.debug( | ||
"Current users: {current_users}, New users: {new_users}, Target users: {target_users}".format( | ||
current_users=current_users, new_users=new_users, target_users=user_count | ||
) | ||
) | ||
# Avoid illegal spawn_rate value of 0 | ||
spawn_rate = max(0.01, new_users) | ||
return (user_count, spawn_rate) | ||
|
||
self.runner.environment.stop_timeout = 0 | ||
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters