Created
December 15, 2014 19:15
-
-
Save hirokai/43a292a82743ba31848a to your computer and use it in GitHub Desktop.
Dispy template (algorithm)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def compute(i): | |
import time,socket | |
host = socket.gethostname() | |
time.sleep(1) | |
return (host, i) | |
def search(): | |
import fnmatch | |
import os | |
matches = [] | |
for root, dirnames, filenames in os.walk('/Volumes/Macintosh HD/Google Drive/Groves/SEM'): | |
for filename in fnmatch.filter(filenames, '*.tiff'): | |
matches.append(os.path.join(root, filename)) | |
return matches | |
def main(n): | |
import time | |
print('testing compute') | |
initiala = time.time() | |
files = search() | |
files = files[0:n] | |
print '%d files.'%(len(files)) | |
import numpy as np | |
spent = [] | |
for i in range(len(files)): | |
initial = time.time() | |
host,res = compute(i) | |
final = time.time() | |
spent.append(final-initial) | |
finala = time.time() | |
print('Process time: %.2f sec (%d jobs, %.3f sec/job)'%(finala-initiala, len(spent), np.mean(spent))) | |
return (finala-initiala, len(spent), np.mean(spent)) | |
if __name__ == '__main__': | |
res = [] | |
for n in [10,30,100,300]: | |
res.append(main(n)) | |
print res |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment