This repository has been archived by the owner on Nov 29, 2023. It is now read-only.
forked from ray-project/ray
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add benchmark using queue (ray-project#2431)
- Loading branch information
1 parent
8e75d15
commit 4225ac5
Showing
1 changed file
with
31 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from __future__ import absolute_import | ||
from __future__ import division | ||
from __future__ import print_function | ||
|
||
import ray | ||
from ray.experimental.queue import Queue | ||
|
||
|
||
def setup(): | ||
if not hasattr(setup, "is_initialized"): | ||
ray.init(num_workers=4, num_cpus=4) | ||
setup.is_initialized = True | ||
|
||
|
||
class QueueSuite(object): | ||
def time_put(self): | ||
queue = Queue(1000) | ||
for i in range(1000): | ||
queue.put(i) | ||
|
||
def time_get(self): | ||
queue = Queue() | ||
for i in range(1000): | ||
queue.put(i) | ||
for _ in range(1000): | ||
queue.get() | ||
|
||
def time_qsize(self): | ||
queue = Queue() | ||
for _ in range(1000): | ||
queue.qsize() |