Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
opendht
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
opendht
Commits
cfeeaf79
Commit
cfeeaf79
authored
5 years ago
by
Seva
Browse files
Options
Downloads
Patches
Plain Diff
tools: add listen & subscribe to proxy_benchmark
parent
e31ebfea
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tools/proxy_benchmark.py
+20
-3
20 additions, 3 deletions
tools/proxy_benchmark.py
with
20 additions
and
3 deletions
tools/proxy_benchmark.py
+
20
−
3
View file @
cfeeaf79
...
...
@@ -14,7 +14,12 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# Run with: locust -f proxy_benchmark.py --host http://127.0.0.1:8080
# Manually run with Web UI:
# locust -f proxy_benchmark.py --host http://127.0.0.1:8080
#
# Run in Terminal:
# locust -f proxy_benchmark.py --host http://127.0.0.1:8080 \
# --clients 100 --hatch-rate 1 --run-time 10s --no-web --only-summary
from
locust
import
HttpLocust
,
TaskSet
from
random
import
randint
...
...
@@ -48,15 +53,27 @@ def get_key(l):
def
get_stats
(
l
):
l
.
client
.
get
(
"
/stats
"
)
def
subscribe
(
l
):
key
=
rand_list_value
(
words
)
print
(
"
Subscribe: key={}
"
.
format
(
key
))
l
.
client
.
get
(
"
/
"
+
key
+
"
/subscribe
"
)
def
listen
(
l
):
key
=
rand_list_value
(
words
)
print
(
"
Listen: key={}
"
.
format
(
key
))
l
.
client
.
get
(
"
/
"
+
key
+
"
/listen
"
)
class
UserBehavior
(
TaskSet
):
tasks
=
{
get_key
:
1
,
put_key
:
1
}
tasks
=
{
get_key
:
5
,
put_key
:
5
,
get_stats
:
1
,
subscribe
:
1
,
listen
:
1
}
def
on_start
(
self
):
put_key
(
self
)
get_key
(
self
)
subscribe
(
self
)
listen
(
self
)
def
on_stop
(
self
):
get_stats
()
get_stats
(
self
)
class
WebsiteUser
(
HttpLocust
):
task_set
=
UserBehavior
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment