Skip to content

Instantly share code, notes, and snippets.

View MasazI's full-sized avatar

Masahiro Imai MasazI

View GitHub Profile
ipython
%timeit l = [0,1,2,3,4,5,6,7,8,9]
%timeit l = (0,1,2,3,4,5,6,7,8,9)
ipython
%timeit l = range(10)
%timeit l = range(100000)
%/usr/bin/time -lp python julia.py [~/source/hppython]
Length of x: 1000
Total elements: 1000000
@timefn: calculate_z_serial_purepython took 7.49427485466seconds
calculate_z_serial_purepython took 7.49432015419 sec
300.0
real 8.54
user 8.40
sys 0.11
144908288 maximum resident set size
@MasazI
MasazI / time.sh
Created December 6, 2015 00:52
usr/bin/time
%/usr/bin/time -p python julia.py [~/source/hppython]
Length of x: 1000
Total elements: 1000000
@timefn: calculate_z_serial_purepython took 7.09809708595seconds
calculate_z_serial_purepython took 7.09813809395 sec
300.0
real 8.06
user 7.95
sys 0.09
%timeit your_function()
@MasazI
MasazI / timeit.sh
Created December 6, 2015 00:41
timeit
python -m timeit -n 5 -r 5 -s "imprort julia" "julia.your_function()"
@MasazI
MasazI / time_print.py
Last active December 6, 2015 00:21
時間計測1 print
start_time = time.time()
~何か処理~
end_time = time.time()
duration = end_time - start_time
print duration
@MasazI
MasazI / cp1_search.py
Created December 3, 2015 15:08
hi performance python cp1 search
def search_1st(haystack, needle):
for item in haystack:
if item == needle:
return True
return False
def search_2nd(haystack, needle):
val = False
for item in haystack:
@MasazI
MasazI / cp1_prime.py
Created December 3, 2015 14:41
hi-performance python cp1
import math
import sys
def check_prime(number):
sqrt_number = math.sqrt(number)
number_float = float(number)
for i in xrange(2, int(sqrt_number)+1):
if (number_float / i).is_integer():
return False
return True
@MasazI
MasazI / gist:574cae9e7f25c3238ba5
Last active November 24, 2015 11:53
good tutorial of opencv3.0 and contlib for ubuntu
http://www.pyimagesearch.com/2015/06/22/install-opencv-3-0-and-python-2-7-on-ubuntu/
notice: change contlib directory.
sudo cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/tools/ -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D OPENCV_EXTRA_MODULES_PATH=/home/deep/tools/opencv_contrib/modules -D BUILD_EXAMPLES=O -D WITH_FFMPEG=OFF -D WITH_CUDA=OFF ..
cd /usr/local/lib/python2.7/site-packages
ln -s /usr/tools/lib/python2.7/dist-packages/cv2.so ./
add pythonpath
/usr/local/lib/python2.7/site-packages