mirror of
https://github.com/jlengrand/project_euler.git
synced 2026-03-10 08:41:20 +00:00
Adds a profiler to help enhancing problem solving
This commit is contained in:
7
euler_profiler
Executable file
7
euler_profiler
Executable file
@@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Used to easily profile a solution to Project Euler
|
||||||
|
|
||||||
|
PROBLEM=$1
|
||||||
|
|
||||||
|
python -m cProfile -s time $PROBLEM
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Brrr this is ugly. You 'd better change it quickly
|
|
||||||
|
|
||||||
TYPE=$1
|
|
||||||
FILE="e_$1.py"
|
|
||||||
|
|
||||||
if [ $# -gt 1 -o $# -lt 1 ];
|
|
||||||
then
|
|
||||||
echo "Main usage is : euler_template number_of_problem"
|
|
||||||
exit 0;
|
|
||||||
fi
|
|
||||||
|
|
||||||
#generating shellbang
|
|
||||||
#echo -e "#!"$(which $TYPE)"\n" >> $FILE
|
|
||||||
echo "#!/usr/bin/env python " >>$FILE
|
|
||||||
|
|
||||||
#generating header
|
|
||||||
echo -e '"""' >> $FILE
|
|
||||||
echo -e " ##---" >> $FILE
|
|
||||||
echo -e " # Julien Lengrand-Lambert" >> $FILE
|
|
||||||
echo -e " #Created on : "$(date)"\n #" >> $FILE
|
|
||||||
echo -e " # DESCRIPTION : Solves problem $1 of Project Euler" >> $FILE
|
|
||||||
echo -e ' ' >> $FILE
|
|
||||||
echo -e " ##---" >> $FILE
|
|
||||||
echo -e '"""' >> $FILE
|
|
||||||
|
|
||||||
# function prototype
|
|
||||||
echo -e 'def fun():' >> $FILE
|
|
||||||
echo -e ' """' >> $FILE
|
|
||||||
echo -e ' """' >> $FILE
|
|
||||||
echo -e ' ' >> $FILE
|
|
||||||
echo -e ' return 1' >> $FILE
|
|
||||||
|
|
||||||
echo -e '' >> $FILE
|
|
||||||
# main
|
|
||||||
echo -e "if __name__ == '__main__':" >> $FILE
|
|
||||||
echo -e ' print "Answer : %d" % (fun())' >> $FILE
|
|
||||||
|
|
||||||
|
|
||||||
chmod +x $FILE
|
|
||||||
Reference in New Issue
Block a user