PERF: Improve slicer.util.importModuleObjects to avoid repeat same file glob
To justify the added complexity, startup times has been measured
for the last 5 commits and, given the experimental setup, it confirms
that this commit slight reduce the startup time.
Results have been gathered on Ubuntu 15.10 on a workstation with the
following specs: 64GB / M.2 PCIe NVMe SSD / Quad Core 3.80GHz
For each commit, the performance have been measured by averaging
the startup time over 15 runs where disk has been flushed before each
run using:
sudo sysctl vm.drop_caches=1
Results are the following:
-
Baseline: ENH: MeasureStartupTimes: Add option to benchmark only regular startup
5.19s
-
Improvement 1: PERF: slicer.util.importClassesFromDirectory: Compile regex outside for loop
5.18s
-
Improvement 2: STYLE: slicer.util.importModuleObjects: Simplify code
5.16s
-
Improvement 3: STYLE: Simplify loading of loadable module python modules
5.18s
-
Improvement 4: PERF: Import loadable module python extension only into 'slicer' module
5.19s
-
Improvement 5: [THIS COMMIT]
5.07s
Automatic collection of stats have been done using shell script
including code like this one:
8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--
what=improvement-5 &&
commit=1234567 &&
desc="PERF: Improve slicer.util.importModuleObjects to avoid repeat same file glob" &&
echo "" &&
echo "$what: $desc" &&
(cd ~/Projects/Slicer && git reset --hard $commit) &&
cmake . &&
make qSlicerBaseQTCore/fast &&
make qSlicerBaseQTGUI/fast &&
make CopySlicerPythonScriptFiles/fast -B &&
make CompileSlicerPythonFiles/fast -B &&
(~/Projects/Slicer/Applications/SlicerApp/Testing/Python/MeasureStartupTimes.py --normal --drop-cache --repeat 15 ./Slicer) &&
cp ./StartupTimesNormal.json ./StartupTimesNormal-$what.json
8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--
git-svn-id: http://svn.slicer.org/Slicer4/trunk@25117 3bd1e089-480b-0410-8dfb-8563597acbee |