Create benchmarking file with --time

Former-commit-id: 8c9f312aff
pull/1161/head
Dakota Benjamin 2016-02-29 09:45:00 -05:00
rodzic e507a276c8
commit 6d0dfa988b
11 zmienionych plików z 72 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')
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('\n %s runtime: %s seconds' % (process, delta))
def run_and_return(cmdSrc, cmdDest=None):
"""Run a system command and return the output"""
process = subprocess.Popen(cmdSrc, stdout=subprocess.PIPE, shell=True)

Wyświetl plik

@ -319,6 +319,9 @@ class ODM_Tree(object):
# important files paths
# benchmarking
self.benchmarking = io.join_paths(self.root_path, 'benchmark.txt')
# opensfm
self.opensfm_bundle = io.join_paths(self.opensfm, 'bundle_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", [])
def process(self, inputs, outputs):
# Benchmarking
start_time = system.now_raw()
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' %
tree.pmvs_bundle)
if args['time']:
system.benchmark(start_time, tree.benchmarking, 'CMVS')
log.ODM_INFO('Running OMD CMVS Cell - Finished')
return ecto.OK if args['end_with'] != 'cmvs' else ecto.QUIT

Wyświetl plik

@ -1,8 +1,10 @@
import ecto
import os
from opendm import context
from opendm import types
from opendm import config
from opendm import io
from dataset import ODMLoadDatasetCell
from resize import ODMResizeCell
@ -70,6 +72,11 @@ class ODMApp(ecto.BlackBox):
tree = types.ODM_Tree(p.args['project_path'])
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)
def connections(self, _p):
# define initial task
# TODO: What is this?

Wyświetl plik

@ -25,6 +25,8 @@ class ODMGeoreferencingCell(ecto.Cell):
outputs.declare("reconstruction", "list of ODMReconstructions", [])
def process(self, inputs, outputs):
# Benchmarking
start_time = system.now_raw()
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'
% tree.odm_georeferencing_model_ply_geo)
if args['time']:
system.benchmark(start_time, tree.benchmarking, 'Georeferencing')
log.ODM_INFO('Running OMD Georeferencing Cell - Finished')
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):
# Benchmarking
start_time = system.now_raw()
log.ODM_INFO('Running OMD Meshing Cell')
# get inputs
@ -67,5 +70,8 @@ class ODMeshingCell(ecto.Cell):
log.ODM_WARNING('Found a valid ODM Mesh file in: %s' %
tree.odm_mesh)
if args['time']:
system.benchmark(start_time, tree.benchmarking, 'Meshing')
log.ODM_INFO('Running OMD Meshing Cell - Finished')
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):
# Benchmarking
start_time = system.now_raw()
log.ODM_INFO('Running OMD OrthoPhoto Cell')
# get inputs
@ -95,5 +98,8 @@ class ODMOrthoPhotoCell(ecto.Cell):
else:
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')
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):
# Benchmarking
start_time = system.now_raw()
log.ODM_INFO('Running OMD Texturing Cell')
# get inputs
@ -66,5 +69,8 @@ class ODMTexturingCell(ecto.Cell):
log.ODM_WARNING('Found a valid ODM Texture file in: %s'
% tree.odm_textured_model_obj)
if args['time']:
system.benchmark(start_time, tree.benchmarking, 'Texturing')
log.ODM_INFO('Running OMD Texturing Cell - Finished')
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):
# Benchmarking
start_time = system.now_raw()
log.ODM_INFO('Running OMD OpenSfm Cell')
# get inputs
@ -97,5 +100,8 @@ class ODMOpenSfMCell(ecto.Cell):
else:
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')
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):
# Benchmarking
start_time = system.now_raw()
log.ODM_INFO('Running OMD PMVS Cell')
# get inputs
@ -72,5 +75,8 @@ class ODMPmvsCell(ecto.Cell):
else:
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')
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):
# Benchmarking
start_time = system.now_raw()
log.ODM_INFO('Running ODM Resize Cell')
# get inputs
@ -91,5 +94,8 @@ class ODMResizeCell(ecto.Cell):
# append photos to cell output
self.outputs.photos = photos
if args['time']:
system.benchmark(start_time, tree.benchmarking, 'Resizing')
log.ODM_INFO('Running ODM Resize Cell - Finished')
return ecto.OK if args['end_with'] != 'resize' else ecto.QUIT