Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
ipaaca
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ramin Yaghoubzadeh Torky
ipaaca
Commits
149e90d8
Commit
149e90d8
authored
13 years ago
by
Ramin Yaghoubzadeh
Browse files
Options
Downloads
Patches
Plain Diff
added ipaaca IU update speed test (ipaacaspam.py) - run without arguments to get some info
parent
4b56e39c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
python/test/src/ipaacaspam.py
+76
-0
76 additions, 0 deletions
python/test/src/ipaacaspam.py
with
76 additions
and
0 deletions
python/test/src/ipaacaspam.py
0 → 100755
+
76
−
0
View file @
149e90d8
#!/usr/bin/env python
import
sys
import
time
import
unittest
import
ipaaca
class
Receiver
(
object
):
def
__init__
(
self
):
self
.
count
=
0
self
.
last_time
=
0
self
.
ib
=
ipaaca
.
InputBuffer
(
'
PowerIn
'
,
[
'
spam
'
])
self
.
ib
.
register_handler
(
self
.
handle_iu_event
)
def
handle_iu_event
(
self
,
iu
,
event_type
,
local
):
if
self
.
count
==
0
:
self
.
last_time
=
time
.
time
()
self
.
count
+=
1
if
self
.
count
==
1000
:
print
"
Received 1k IU updates at
"
,
int
(
1000.0
/
(
time
.
time
()
-
self
.
last_time
)),
"
Hz
"
self
.
count
=
0
def
run
(
self
):
while
True
:
time
.
sleep
(
1
)
class
Sender
(
object
):
def
__init__
(
self
,
send_frequency
):
self
.
ob
=
ipaaca
.
OutputBuffer
(
'
PowerOut
'
)
self
.
iu
=
ipaaca
.
IU
(
'
spam
'
)
self
.
iu
.
payload
=
{
'
data
'
:
'
0
'
}
self
.
ob
.
add
(
self
.
iu
)
self
.
counter
=
0
self
.
frequency
=
send_frequency
self
.
delay
=
1.0
/
send_frequency
def
run
(
self
):
print
"
Sending with
"
,
self
.
delay
,
"
s delay - upper bound
"
,
self
.
frequency
,
"
Hz ...
"
last_time
=
time
.
time
()
while
True
:
time
.
sleep
(
self
.
delay
)
self
.
counter
+=
1
self
.
iu
.
payload
[
'
data
'
]
=
str
(
self
.
counter
)
if
self
.
counter
==
1000
:
print
"
Sent 1k updates at
"
,
int
(
1000.0
/
(
time
.
time
()
-
last_time
)),
"
Hz
"
last_time
=
time
.
time
()
self
.
counter
=
0
#print ".",
#sys.stdout.flush()
if
__name__
==
'
__main__
'
:
if
len
(
sys
.
argv
)
<
2
:
print
"
specify either
'
sender
'
or
'
receiver
'
as an argument
"
print
"
for the sender, you can additionally specify a delay (in 1/s)
"
print
"
between 1 and 10000 please (=> 1 sec ... 0.0001 sec) [default: 1000 => 0.001 sec]
"
sys
.
exit
(
1
)
if
sys
.
argv
[
1
]
==
'
receiver
'
:
r
=
Receiver
()
r
.
run
()
elif
sys
.
argv
[
1
]
==
'
sender
'
:
freq
=
1000
try
:
freq
=
int
(
sys
.
argv
[
2
])
except
:
pass
if
freq
<
1
or
freq
>
10000
:
print
"
Between 1 and 10000 please (=> 1 sec ... 0.0001 sec)
"
sys
.
exit
(
1
)
s
=
Sender
(
send_frequency
=
freq
)
s
.
run
()
else
:
print
"
specify either
'
sender
'
or
'
receiver
'
as an argument
"
sys
.
exit
(
1
)
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