Browse Source

fix ./run to allow simple profiling. add --profile before script name

ephraim 3 years ago
parent
commit
a5823bc833
1 changed files with 17 additions and 2 deletions
  1. 17 2
      run

+ 17 - 2
run

@@ -11,6 +11,11 @@ if [ $# -eq 0 ]; then
     exit 1
 fi
 
+if [ "$1" = "--profile" ] ; then
+    profilescript=true
+    shift
+fi
+
 # look in scripts/ by default
 if [ -e $DIR/scripts/$1 ]; then
     script="$DIR/scripts/$1"
@@ -19,8 +24,18 @@ else
 fi
 
 if [ $# -eq 1 ]; then
-    python $script
+    if [ "$profilescript" = true ] ; then
+        echo "profiling"
+        python -m cProfile $script
+    else
+        python $script
+    fi
 elif [ $# -ge 2 ]; then
     passargs=("${@:2}")
-    python $script "${passargs[@]}"
+    if [ "$profilescript" = true ] ; then
+        echo "profiling"
+        python -m cProfile $script "${passargs[@]}"
+    else
+        python $script "${passargs[@]}"
+    fi
 fi