Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Property access benchmarking: timeit-based shell script #732

Open
wants to merge 3 commits into
base: ev3dev-stretch
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions utils/benchmarking/benchmark-results.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Historical I/O benchmark results

Procedure: Use an EV3. Disconnect all peripherals, including Wi-Fi. Connect one large EV3 motor. Cold-boot the EV3 and
leave it for around five minutes to make sure all services have loaded. Execute `io-benchmark.sh` from the Brickman
interface. Then grab the `benchmark.txt` file from the same directory.

TODO: instructions for installing from sources with Makefile?

## `2.1.0` release
System info:
```
Image file: ev3dev-stretch-ev3-generic-2019-05-29
Kernel version: 4.14.117-ev3dev-2.3.4-ev3
Brickman: 0.10.1
BogoMIPS: 148.88
Bluetooth:
Board: board0
BOARD_INFO_HW_REV=7
BOARD_INFO_MODEL=LEGO MINDSTORMS EV3
BOARD_INFO_ROM_REV=6
BOARD_INFO_SERIAL_NUM=00165340720B
BOARD_INFO_TYPE=main
```

Benchmark results:
```
Using interpreter python3; found ev3dev2 version 2.1.0 from /usr/lib/python3/dist-packages/ev3dev2
Motor read address:
1000 loops, best of 3: 970 usec per loop
Motor read speed_sp:
1000 loops, best of 3: 1.1 msec per loop
Motor read count_per_rot (cached):
1000 loops, best of 3: 215 usec per loop
Motor write speed_sp:
1000 loops, best of 3: 1.12 msec per loop
Using interpreter micropython; found ev3dev2 version 2.1.0 from /usr/lib/micropython/ev3dev2
Motor read address:
1000 loops, best of 3: 1.21 msec per loop
Motor read speed_sp:
1000 loops, best of 3: 1.17 msec per loop
Motor read count_per_rot (cached):
10000 loops, best of 3: 144 usec per loop
Motor write speed_sp:
1000 loops, best of 3: 1.08 msec per loop
```
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks pretty cool. I think some newlines in the output would help make it a little more readable but that is minor.

LGTM

27 changes: 27 additions & 0 deletions utils/benchmarking/io-benchmark.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

exec &> >(tee benchmark.txt)

do_benchmark() {
PYTHON=$1

VERSION=$($PYTHON -c "import ev3dev2; print(ev3dev2.__version__)")
MODULE_PATH=$($PYTHON -c "import ev3dev2; print(ev3dev2.__path__[0] if isinstance(ev3dev2.__path__, list) else ev3dev2.__path__)")

echo "Using interpreter $PYTHON; found ev3dev2 version $VERSION from $MODULE_PATH"

echo "Motor read address:"
$PYTHON -m timeit -s "from ev3dev2.motor import Motor; m = Motor()" "m.address"

echo "Motor read speed_sp:"
$PYTHON -m timeit -s "from ev3dev2.motor import Motor; m = Motor()" "m.speed_sp"

echo "Motor read count_per_rot (cached):"
$PYTHON -m timeit -s "from ev3dev2.motor import Motor; m = Motor()" "m.count_per_rot"

echo "Motor write speed_sp:"
$PYTHON -m timeit -s "from ev3dev2.motor import Motor; m = Motor()" "m.speed_sp = 5"
}

do_benchmark python3
do_benchmark micropython