summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkotfu <kotfu@kotfu.net>2018-05-06 13:38:40 -0600
committerkotfu <kotfu@kotfu.net>2018-05-06 13:38:40 -0600
commita1cbef5b4af0831ad57e4eaa75bdd77c15cb004b (patch)
tree28ba17ea3f257cbf74ac70d510dcfd1566a6e606
parentfbbfe256cd23f87e5aad1dc4858c5e7c7753352b (diff)
downloadcmd2-git-a1cbef5b4af0831ad57e4eaa75bdd77c15cb004b.tar.gz
Add measurement script and document to track progress
-rwxr-xr-xmtime.sh14
-rw-r--r--speedup_import.md36
2 files changed, 50 insertions, 0 deletions
diff --git a/mtime.sh b/mtime.sh
new file mode 100755
index 00000000..1cb5f8dc
--- /dev/null
+++ b/mtime.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+TMPFILE=`mktemp /tmp/mtime.XXXXXX` || exit 1
+
+for x in {1..100}
+do
+ gtime -f "real %e user %U sys %S" -a -o $TMPFILE "$@"
+ #tail -1 $TMPFILE
+done
+
+awk '{ et += $2; ut += $4; st += $6; count++ } END { printf "%d iterations\n", count ; printf "average: real %.3f user %.3f sys %.3f\n", et/count, ut/count, st/count }' $TMPFILE
+
+rm $TMPFILE
+
diff --git a/speedup_import.md b/speedup_import.md
new file mode 100644
index 00000000..12d95bf3
--- /dev/null
+++ b/speedup_import.md
@@ -0,0 +1,36 @@
+# Speedup Import
+
+## Assumptions
+
+I created a simple script to run a command 20 times and calculate
+the average clock time for each run of the command. This script requires
+some unix tools, including the gnu flavor of the `time` command. This script
+can is called `mtime.sh` and is included in this branch.
+
+These tests were all run on my 2015 MacBook Pro with a 3.1 GHz Intel Core i7
+and 16GB of memory.
+
+
+## Baseline measurement
+
+First let's see how long it takes to start up python. The longish path here
+ensures we aren't measuring the time it takes the pyenv shims to run:
+```
+$./mtime.sh ~/.pyenv/versions/cmd2-3.6/bin/python -c ""
+100 iterations
+average: real 0.028 user 0.020 sys 0.000
+```
+
+## Initial measurement
+
+From commit c7753352b, which has `__init.py__` importing `cmd2.cmd2.Cmd`
+and a bunch of other stuff, we get:
+```
+$ ./mtime.sh ~/.pyenv/versions/cmd2-3.6/bin/python -c "import cmd2"
+100 iterations
+average: real 0.140 user 0.100 sys 0.030
+```
+
+From the baseline and this initial measurement, we infer it takes ~110 ms
+to import the `cmd2` module.
+