From a009348cf365744f0a422959a078f2c148cadc8b Mon Sep 17 00:00:00 2001 From: Kaelin Laundry Date: Wed, 25 Mar 2020 22:33:28 -0700 Subject: [PATCH 1/3] WIP benchmarking script --- utils/benchmarking/io-benchmark.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 utils/benchmarking/io-benchmark.sh diff --git a/utils/benchmarking/io-benchmark.sh b/utils/benchmarking/io-benchmark.sh new file mode 100644 index 0000000..f1486b5 --- /dev/null +++ b/utils/benchmarking/io-benchmark.sh @@ -0,0 +1,24 @@ +#!/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__)") + + 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 write speed_sp:" + $PYTHON -m timeit -s "from ev3dev2.motor import Motor; m = Motor()" "m.speed_sp = 5" +} + +do_benchmark python3 +do_benchmark micropython From 280d7b4157cc48e3e37a6780b9b69341b327a77d Mon Sep 17 00:00:00 2001 From: Kaelin Laundry Date: Thu, 26 Mar 2020 01:32:13 -0700 Subject: [PATCH 2/3] Better print --- utils/benchmarking/io-benchmark.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/benchmarking/io-benchmark.sh b/utils/benchmarking/io-benchmark.sh index f1486b5..8751a38 100644 --- a/utils/benchmarking/io-benchmark.sh +++ b/utils/benchmarking/io-benchmark.sh @@ -6,7 +6,7 @@ do_benchmark() { PYTHON=$1 VERSION=$($PYTHON -c "import ev3dev2; print(ev3dev2.__version__)") - MODULE_PATH=$($PYTHON -c "import ev3dev2; print(ev3dev2.__path__)") + 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" From 97386a052277c17aa65f43c89167e176b709d69b Mon Sep 17 00:00:00 2001 From: Kaelin Laundry Date: Thu, 26 Mar 2020 02:45:48 -0700 Subject: [PATCH 3/3] also benchmark cached prop; results doc --- utils/benchmarking/benchmark-results.md | 45 +++++++++++++++++++++++++ utils/benchmarking/io-benchmark.sh | 3 ++ 2 files changed, 48 insertions(+) create mode 100644 utils/benchmarking/benchmark-results.md diff --git a/utils/benchmarking/benchmark-results.md b/utils/benchmarking/benchmark-results.md new file mode 100644 index 0000000..fbc3824 --- /dev/null +++ b/utils/benchmarking/benchmark-results.md @@ -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 +``` \ No newline at end of file diff --git a/utils/benchmarking/io-benchmark.sh b/utils/benchmarking/io-benchmark.sh index 8751a38..903e18a 100644 --- a/utils/benchmarking/io-benchmark.sh +++ b/utils/benchmarking/io-benchmark.sh @@ -15,6 +15,9 @@ do_benchmark() { 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"