Skip to content

Commit a1cbef5

Browse files
committed
Add measurement script and document to track progress
1 parent fbbfe25 commit a1cbef5

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

mtime.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
TMPFILE=`mktemp /tmp/mtime.XXXXXX` || exit 1
4+
5+
for x in {1..100}
6+
do
7+
gtime -f "real %e user %U sys %S" -a -o $TMPFILE "$@"
8+
#tail -1 $TMPFILE
9+
done
10+
11+
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
12+
13+
rm $TMPFILE
14+

speedup_import.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Speedup Import
2+
3+
## Assumptions
4+
5+
I created a simple script to run a command 20 times and calculate
6+
the average clock time for each run of the command. This script requires
7+
some unix tools, including the gnu flavor of the `time` command. This script
8+
can is called `mtime.sh` and is included in this branch.
9+
10+
These tests were all run on my 2015 MacBook Pro with a 3.1 GHz Intel Core i7
11+
and 16GB of memory.
12+
13+
14+
## Baseline measurement
15+
16+
First let's see how long it takes to start up python. The longish path here
17+
ensures we aren't measuring the time it takes the pyenv shims to run:
18+
```
19+
$./mtime.sh ~/.pyenv/versions/cmd2-3.6/bin/python -c ""
20+
100 iterations
21+
average: real 0.028 user 0.020 sys 0.000
22+
```
23+
24+
## Initial measurement
25+
26+
From commit c7753352b, which has `__init.py__` importing `cmd2.cmd2.Cmd`
27+
and a bunch of other stuff, we get:
28+
```
29+
$ ./mtime.sh ~/.pyenv/versions/cmd2-3.6/bin/python -c "import cmd2"
30+
100 iterations
31+
average: real 0.140 user 0.100 sys 0.030
32+
```
33+
34+
From the baseline and this initial measurement, we infer it takes ~110 ms
35+
to import the `cmd2` module.
36+

0 commit comments

Comments
 (0)