Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
beat.core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
beat
beat.core
Commits
f05f95d6
Commit
f05f95d6
authored
6 years ago
by
Samuel GAIST
Browse files
Options
Downloads
Patches
Plain Diff
[scripts] Cleanup using black
parent
356f6ff4
No related branches found
No related tags found
1 merge request
!62
Code cleanup
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
beat/core/scripts/benchmark.py
+44
-40
44 additions, 40 deletions
beat/core/scripts/benchmark.py
with
44 additions
and
40 deletions
beat/core/scripts/benchmark.py
+
44
−
40
View file @
f05f95d6
...
@@ -12,18 +12,16 @@ import time
...
@@ -12,18 +12,16 @@ import time
import
zmq
import
zmq
prefix
=
pkg_resources
.
resource_filename
(
__name__
,
'
../test/prefix
'
)
prefix
=
pkg_resources
.
resource_filename
(
__name__
,
"
../test/prefix
"
)
print
(
prefix
)
print
(
prefix
)
class
CustomDataSource
(
DataSource
):
class
CustomDataSource
(
DataSource
):
def
__init__
(
self
,
nb_data_units
,
dataformat
):
def
__init__
(
self
,
nb_data_units
,
dataformat
):
self
.
nb_data_units
=
nb_data_units
self
.
nb_data_units
=
nb_data_units
self
.
current
=
0
self
.
current
=
0
self
.
dataformat
=
dataformat
self
.
dataformat
=
dataformat
self
.
file
=
open
(
'
benchmark.data
'
,
'
rb
'
)
self
.
file
=
open
(
"
benchmark.data
"
,
"
rb
"
)
self
.
unpack
=
True
self
.
unpack
=
True
def
next
(
self
):
def
next
(
self
):
...
@@ -50,20 +48,20 @@ class CustomDataSource(DataSource):
...
@@ -50,20 +48,20 @@ class CustomDataSource(DataSource):
def
main
():
def
main
():
dataformat
=
DataFormat
(
prefix
,
'
user/empty_1d_array_of_integers/1
'
)
dataformat
=
DataFormat
(
prefix
,
"
user/empty_1d_array_of_integers/1
"
)
data
=
dataformat
.
type
(
value
=
np
.
random
.
randint
(
100000
,
size
=
(
1000000
,),
dtype
=
np
.
int32
))
data
=
dataformat
.
type
(
value
=
np
.
random
.
randint
(
100000
,
size
=
(
1000000
,),
dtype
=
np
.
int32
)
)
with
open
(
'
benchmark.data
'
,
'
wb
'
)
as
f
:
with
open
(
"
benchmark.data
"
,
"
wb
"
)
as
f
:
f
.
write
(
data
.
pack
())
f
.
write
(
data
.
pack
())
# -----------------------
#-----------------------
data_source
=
CustomDataSource
(
10000
,
dataformat
)
data_source
=
CustomDataSource
(
10000
,
dataformat
)
print
(
'
Nb Data units: %d
'
%
data_source
.
nb_data_units
)
print
(
"
Nb Data units: %d
"
%
data_source
.
nb_data_units
)
t1
=
time
.
time
()
t1
=
time
.
time
()
...
@@ -72,12 +70,14 @@ def main():
...
@@ -72,12 +70,14 @@ def main():
t2
=
time
.
time
()
t2
=
time
.
time
()
print
(
'
Datasource (unpack): %.3fs (%.3fms/unit)
'
%
(
t2
-
t1
,
(
t2
-
t1
)
*
1000.0
/
data_source
.
nb_data_units
))
print
(
"
Datasource (unpack): %.3fs (%.3fms/unit)
"
%
(
t2
-
t1
,
(
t2
-
t1
)
*
1000.0
/
data_source
.
nb_data_units
)
)
data_source
.
reset
()
data_source
.
reset
()
# -----------------------
#-----------------------
data_source
.
unpack
=
False
data_source
.
unpack
=
False
...
@@ -88,16 +88,16 @@ def main():
...
@@ -88,16 +88,16 @@ def main():
t2
=
time
.
time
()
t2
=
time
.
time
()
print
(
'
Datasource (packed): %.3fs (%.3fms/unit)
'
%
(
t2
-
t1
,
(
t2
-
t1
)
*
1000.0
/
data_source
.
nb_data_units
))
print
(
"
Datasource (packed): %.3fs (%.3fms/unit)
"
%
(
t2
-
t1
,
(
t2
-
t1
)
*
1000.0
/
data_source
.
nb_data_units
)
)
data_source
.
reset
()
data_source
.
reset
()
# -----------------------
#-----------------------
input
=
Input
(
"
a
"
,
"
user/empty_1d_array_of_integers/1
"
,
data_source
)
input
=
Input
(
'
a
'
,
'
user/empty_1d_array_of_integers/1
'
,
data_source
)
t1
=
time
.
time
()
t1
=
time
.
time
()
...
@@ -106,13 +106,14 @@ def main():
...
@@ -106,13 +106,14 @@ def main():
t2
=
time
.
time
()
t2
=
time
.
time
()
print
(
'
Input (unpack): %.3fs (%.3fms/unit)
'
%
(
t2
-
t1
,
(
t2
-
t1
)
*
1000.0
/
data_source
.
nb_data_units
))
print
(
"
Input (unpack): %.3fs (%.3fms/unit)
"
%
(
t2
-
t1
,
(
t2
-
t1
)
*
1000.0
/
data_source
.
nb_data_units
)
)
data_source
.
reset
()
data_source
.
reset
()
# -----------------------
#-----------------------
data_source
.
unpack
=
False
data_source
.
unpack
=
False
...
@@ -123,37 +124,36 @@ def main():
...
@@ -123,37 +124,36 @@ def main():
t2
=
time
.
time
()
t2
=
time
.
time
()
print
(
'
Input (packed): %.3fs (%.3fms/unit)
'
%
(
t2
-
t1
,
(
t2
-
t1
)
*
1000.0
/
data_source
.
nb_data_units
))
print
(
"
Input (packed): %.3fs (%.3fms/unit)
"
%
(
t2
-
t1
,
(
t2
-
t1
)
*
1000.0
/
data_source
.
nb_data_units
)
)
data_source
.
reset
()
data_source
.
reset
()
# -----------------------
#-----------------------
group
=
InputGroup
(
"
channel
"
)
group
=
InputGroup
(
'
channel
'
)
group
.
add
(
input
)
group
.
add
(
input
)
input_list
=
InputList
()
input_list
=
InputList
()
input_list
.
add
(
group
)
input_list
.
add
(
group
)
server_context
=
zmq
.
Context
()
server_context
=
zmq
.
Context
()
server_socket
=
server_context
.
socket
(
zmq
.
PAIR
)
server_socket
=
server_context
.
socket
(
zmq
.
PAIR
)
address
=
'
tcp://127.0.0.1
'
address
=
"
tcp://127.0.0.1
"
port
=
server_socket
.
bind_to_random_port
(
address
)
port
=
server_socket
.
bind_to_random_port
(
address
)
address
+=
'
:%d
'
%
port
address
+=
"
:%d
"
%
port
message_handler
=
MessageHandler
(
input_list
,
server_context
,
server_socket
)
message_handler
=
MessageHandler
(
input_list
,
server_context
,
server_socket
)
client_context
=
zmq
.
Context
()
client_context
=
zmq
.
Context
()
client_socket
=
client_context
.
socket
(
zmq
.
PAIR
)
client_socket
=
client_context
.
socket
(
zmq
.
PAIR
)
client_socket
.
connect
(
address
)
client_socket
.
connect
(
address
)
remote_input
=
RemoteInput
(
'
a
'
,
dataformat
,
client_socket
)
remote_input
=
RemoteInput
(
"
a
"
,
dataformat
,
client_socket
)
remote_group
=
InputGroup
(
'
channel
'
,
restricted_access
=
False
)
remote_group
=
InputGroup
(
"
channel
"
,
restricted_access
=
False
)
remote_group
.
add
(
remote_input
)
remote_group
.
add
(
remote_input
)
remote_input_list
=
InputList
()
remote_input_list
=
InputList
()
...
@@ -161,7 +161,6 @@ def main():
...
@@ -161,7 +161,6 @@ def main():
message_handler
.
start
()
message_handler
.
start
()
t1
=
time
.
time
()
t1
=
time
.
time
()
while
remote_input
.
hasMoreData
():
while
remote_input
.
hasMoreData
():
...
@@ -169,12 +168,14 @@ def main():
...
@@ -169,12 +168,14 @@ def main():
t2
=
time
.
time
()
t2
=
time
.
time
()
print
(
'
Remote (unpack): %.3fs (%.3fms/unit)
'
%
(
t2
-
t1
,
(
t2
-
t1
)
*
1000.0
/
data_source
.
nb_data_units
))
print
(
"
Remote (unpack): %.3fs (%.3fms/unit)
"
%
(
t2
-
t1
,
(
t2
-
t1
)
*
1000.0
/
data_source
.
nb_data_units
)
)
data_source
.
reset
()
data_source
.
reset
()
# -----------------------
#-----------------------
data_source
.
unpack
=
False
data_source
.
unpack
=
False
# message_handler.unpack = False
# message_handler.unpack = False
...
@@ -186,6 +187,9 @@ def main():
...
@@ -186,6 +187,9 @@ def main():
t2
=
time
.
time
()
t2
=
time
.
time
()
print
(
'
Remote (packed): %.3fs (%.3fms/unit)
'
%
(
t2
-
t1
,
(
t2
-
t1
)
*
1000.0
/
data_source
.
nb_data_units
))
print
(
"
Remote (packed): %.3fs (%.3fms/unit)
"
%
(
t2
-
t1
,
(
t2
-
t1
)
*
1000.0
/
data_source
.
nb_data_units
)
)
data_source
.
reset
()
data_source
.
reset
()
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