Merge pull request #264 from dakotabenjamin/benchmarking

Benchmarking
pull/267/head
Dakota Benjamin 2016-03-02 08:29:36 -05:00
commit fea6bcccbe
11 zmienionych plików z 75 dodań i 0 usunięć

Wyświetl plik

@ -31,6 +31,21 @@ def now():
return datetime.datetime.now().strftime('%a %b %d %H:%M:%S %Z %Y') return datetime.datetime.now().strftime('%a %b %d %H:%M:%S %Z %Y')
def now_raw():
return datetime.datetime.now()
def benchmark(start, benchmarking_file, process):
"""
runs a benchmark with a start datetime object
:return: the running time (delta)
"""
# Write to benchmark file
delta = (datetime.datetime.now() - start).total_seconds()
with open(benchmarking_file, 'a') as b:
b.write('%s runtime: %s seconds\n' % (process, delta))
def run_and_return(cmdSrc, cmdDest=None): def run_and_return(cmdSrc, cmdDest=None):
"""Run a system command and return the output""" """Run a system command and return the output"""
process = subprocess.Popen(cmdSrc, stdout=subprocess.PIPE, shell=True) process = subprocess.Popen(cmdSrc, stdout=subprocess.PIPE, shell=True)

Wyświetl plik

@ -319,6 +319,9 @@ class ODM_Tree(object):
# important files paths # important files paths
# benchmarking
self.benchmarking = io.join_paths(self.root_path, 'benchmark.txt')
# opensfm # opensfm
self.opensfm_bundle = io.join_paths(self.opensfm, 'bundle_r000.out') self.opensfm_bundle = io.join_paths(self.opensfm, 'bundle_r000.out')
self.opensfm_bundle_list = io.join_paths(self.opensfm, 'list_r000.out') self.opensfm_bundle_list = io.join_paths(self.opensfm, 'list_r000.out')

Wyświetl plik

@ -21,6 +21,9 @@ class ODMCmvsCell(ecto.Cell):
outputs.declare("reconstruction", "list of ODMReconstructions", []) outputs.declare("reconstruction", "list of ODMReconstructions", [])
def process(self, inputs, outputs): def process(self, inputs, outputs):
# Benchmarking
start_time = system.now_raw()
log.ODM_INFO('Running OMD CMVS Cell') log.ODM_INFO('Running OMD CMVS Cell')
@ -56,5 +59,8 @@ class ODMCmvsCell(ecto.Cell):
log.ODM_WARNING('Found a valid CMVS file in: %s' % log.ODM_WARNING('Found a valid CMVS file in: %s' %
tree.pmvs_bundle) tree.pmvs_bundle)
if args['time']:
system.benchmark(start_time, tree.benchmarking, 'CMVS')
log.ODM_INFO('Running OMD CMVS Cell - Finished') log.ODM_INFO('Running OMD CMVS Cell - Finished')
return ecto.OK if args['end_with'] != 'cmvs' else ecto.QUIT return ecto.OK if args['end_with'] != 'cmvs' else ecto.QUIT

Wyświetl plik

@ -1,8 +1,11 @@
import ecto import ecto
import os
from opendm import context from opendm import context
from opendm import types from opendm import types
from opendm import config from opendm import config
from opendm import io
from opendm import system
from dataset import ODMLoadDatasetCell from dataset import ODMLoadDatasetCell
from resize import ODMResizeCell from resize import ODMResizeCell
@ -70,6 +73,13 @@ class ODMApp(ecto.BlackBox):
tree = types.ODM_Tree(p.args['project_path']) tree = types.ODM_Tree(p.args['project_path'])
self.tree = ecto.Constant(value=tree) self.tree = ecto.Constant(value=tree)
# TODO(dakota) put this somewhere better maybe
if config.args.get('time') and io.file_exists(tree.benchmarking):
# Delete the previously made file
os.remove(tree.benchmarking)
with open(tree.benchmarking, 'a') as b:
b.write('ODM Benchmarking file created %s\nNumber of Cores: %s\n\n' % (system.now(), context.num_cores))
def connections(self, _p): def connections(self, _p):
# define initial task # define initial task
# TODO: What is this? # TODO: What is this?

Wyświetl plik

@ -25,6 +25,8 @@ class ODMGeoreferencingCell(ecto.Cell):
outputs.declare("reconstruction", "list of ODMReconstructions", []) outputs.declare("reconstruction", "list of ODMReconstructions", [])
def process(self, inputs, outputs): def process(self, inputs, outputs):
# Benchmarking
start_time = system.now_raw()
log.ODM_INFO('Running OMD Georeferencing Cell') log.ODM_INFO('Running OMD Georeferencing Cell')
@ -139,5 +141,8 @@ class ODMGeoreferencingCell(ecto.Cell):
log.ODM_WARNING('Found a valid georeferenced model in: %s' log.ODM_WARNING('Found a valid georeferenced model in: %s'
% tree.odm_georeferencing_model_ply_geo) % tree.odm_georeferencing_model_ply_geo)
if args['time']:
system.benchmark(start_time, tree.benchmarking, 'Georeferencing')
log.ODM_INFO('Running OMD Georeferencing Cell - Finished') log.ODM_INFO('Running OMD Georeferencing Cell - Finished')
return ecto.OK if args['end_with'] != 'odm_georeferencing' else ecto.QUIT return ecto.OK if args['end_with'] != 'odm_georeferencing' else ecto.QUIT

Wyświetl plik

@ -28,6 +28,9 @@ class ODMeshingCell(ecto.Cell):
def process(self, inputs, outputs): def process(self, inputs, outputs):
# Benchmarking
start_time = system.now_raw()
log.ODM_INFO('Running OMD Meshing Cell') log.ODM_INFO('Running OMD Meshing Cell')
# get inputs # get inputs
@ -67,5 +70,8 @@ class ODMeshingCell(ecto.Cell):
log.ODM_WARNING('Found a valid ODM Mesh file in: %s' % log.ODM_WARNING('Found a valid ODM Mesh file in: %s' %
tree.odm_mesh) tree.odm_mesh)
if args['time']:
system.benchmark(start_time, tree.benchmarking, 'Meshing')
log.ODM_INFO('Running OMD Meshing Cell - Finished') log.ODM_INFO('Running OMD Meshing Cell - Finished')
return ecto.OK if args['end_with'] != 'odm_meshing' else ecto.QUIT return ecto.OK if args['end_with'] != 'odm_meshing' else ecto.QUIT

Wyświetl plik

@ -18,6 +18,9 @@ class ODMOrthoPhotoCell(ecto.Cell):
def process(self, inputs, outputs): def process(self, inputs, outputs):
# Benchmarking
start_time = system.now_raw()
log.ODM_INFO('Running OMD OrthoPhoto Cell') log.ODM_INFO('Running OMD OrthoPhoto Cell')
# get inputs # get inputs
@ -95,5 +98,8 @@ class ODMOrthoPhotoCell(ecto.Cell):
else: else:
log.ODM_WARNING('Found a valid orthophoto in: %s' % tree.odm_orthophoto_file) log.ODM_WARNING('Found a valid orthophoto in: %s' % tree.odm_orthophoto_file)
if args['time']:
system.benchmark(start_time, tree.benchmarking, 'Orthophoto')
log.ODM_INFO('Running OMD OrthoPhoto Cell - Finished') log.ODM_INFO('Running OMD OrthoPhoto Cell - Finished')
return ecto.OK if args['end_with'] != 'odm_orthophoto' else ecto.QUIT return ecto.OK if args['end_with'] != 'odm_orthophoto' else ecto.QUIT

Wyświetl plik

@ -22,6 +22,9 @@ class ODMTexturingCell(ecto.Cell):
def process(self, inputs, outputs): def process(self, inputs, outputs):
# Benchmarking
start_time = system.now_raw()
log.ODM_INFO('Running OMD Texturing Cell') log.ODM_INFO('Running OMD Texturing Cell')
# get inputs # get inputs
@ -66,5 +69,8 @@ class ODMTexturingCell(ecto.Cell):
log.ODM_WARNING('Found a valid ODM Texture file in: %s' log.ODM_WARNING('Found a valid ODM Texture file in: %s'
% tree.odm_textured_model_obj) % tree.odm_textured_model_obj)
if args['time']:
system.benchmark(start_time, tree.benchmarking, 'Texturing')
log.ODM_INFO('Running OMD Texturing Cell - Finished') log.ODM_INFO('Running OMD Texturing Cell - Finished')
return ecto.OK if args['end_with'] != 'odm_texturing' else ecto.QUIT return ecto.OK if args['end_with'] != 'odm_texturing' else ecto.QUIT

Wyświetl plik

@ -23,6 +23,9 @@ class ODMOpenSfMCell(ecto.Cell):
def process(self, inputs, outputs): def process(self, inputs, outputs):
# Benchmarking
start_time = system.now_raw()
log.ODM_INFO('Running OMD OpenSfm Cell') log.ODM_INFO('Running OMD OpenSfm Cell')
# get inputs # get inputs
@ -97,5 +100,8 @@ class ODMOpenSfMCell(ecto.Cell):
else: else:
log.ODM_WARNING('Found a valid CMVS file in: %s' % tree.pmvs_visdat) log.ODM_WARNING('Found a valid CMVS file in: %s' % tree.pmvs_visdat)
if args['time']:
system.benchmark(start_time, tree.benchmarking, 'OpenSfM')
log.ODM_INFO('Running OMD OpenSfm Cell - Finished') log.ODM_INFO('Running OMD OpenSfm Cell - Finished')
return ecto.OK if args['end_with'] != 'opensfm' else ecto.QUIT return ecto.OK if args['end_with'] != 'opensfm' else ecto.QUIT

Wyświetl plik

@ -34,6 +34,9 @@ class ODMPmvsCell(ecto.Cell):
def process(self, inputs, outputs): def process(self, inputs, outputs):
# Benchmarking
start_time = system.now_raw()
log.ODM_INFO('Running OMD PMVS Cell') log.ODM_INFO('Running OMD PMVS Cell')
# get inputs # get inputs
@ -72,5 +75,8 @@ class ODMPmvsCell(ecto.Cell):
else: else:
log.ODM_WARNING('Found a valid PMVS file in %s' % tree.pmvs_model) log.ODM_WARNING('Found a valid PMVS file in %s' % tree.pmvs_model)
if args['time']:
system.benchmark(start_time, tree.benchmarking, 'PMVS')
log.ODM_INFO('Running OMD PMVS Cell - Finished') log.ODM_INFO('Running OMD PMVS Cell - Finished')
return ecto.OK if args['end_with'] != 'pmvs' else ecto.QUIT return ecto.OK if args['end_with'] != 'pmvs' else ecto.QUIT

Wyświetl plik

@ -20,6 +20,9 @@ class ODMResizeCell(ecto.Cell):
def process(self, inputs, outputs): def process(self, inputs, outputs):
# Benchmarking
start_time = system.now_raw()
log.ODM_INFO('Running ODM Resize Cell') log.ODM_INFO('Running ODM Resize Cell')
# get inputs # get inputs
@ -91,5 +94,8 @@ class ODMResizeCell(ecto.Cell):
# append photos to cell output # append photos to cell output
self.outputs.photos = photos self.outputs.photos = photos
if args['time']:
system.benchmark(start_time, tree.benchmarking, 'Resizing')
log.ODM_INFO('Running ODM Resize Cell - Finished') log.ODM_INFO('Running ODM Resize Cell - Finished')
return ecto.OK if args['end_with'] != 'resize' else ecto.QUIT return ecto.OK if args['end_with'] != 'resize' else ecto.QUIT