Did some test with timing. Now i know where the bottleneck is:
Results:
(0.009768962860107422, '**************************************************', 'STARTING')
(0.016762971878051758, '**************************************************', 'CREATED FILE OBJECT')
(0.02452397346496582, '**************************************************', 'GOT FILE NAMING')
(0.12882614135742188, '**************************************************', 'GOT FILE NAME', u'EpTEST_Sh01_animation_v001')
(0.12989497184753418, '**************************************************', 'GOT DIRS')
(0.18693208694458008, '**************************************************', 'GOR LIB DIR', u'/home/apache/assets/dolly3d/episodes/EpTEST/animation/versions')
client_repo
(0.25337696075439453, '**************************************************', 'GOT REPOS', u'/home/apache/assets/dolly3d/episodes/EpTEST/animation/versions')
/home/apache/assets/dolly3d/episodes/EpTEST/animation/versions/EpTEST_Sh01_animation_v001
(0.0014290809631347656, '**************************************************', 'STARTING')
(0.0025000572204589844, '**************************************************', 'CREATED FILE OBJECT')
(0.003049135208129883, '**************************************************', 'GOT FILE NAMING')
(0.03217816352844238, '**************************************************', 'GOT FILE NAME', u'EpTEST_Sh01')
(0.03326010704040527, '**************************************************', 'GOT DIRS')
(0.08859395980834961, '**************************************************', 'GOR LIB DIR', u'/home/apache/assets/dolly3d/episodes/EpTEST')
client_repo
(0.1293330192565918, '**************************************************', 'GOT REPOS', u'/home/apache/assets/dolly3d/episodes/EpTEST')
/home/apache/assets/dolly3d/episodes/EpTEST/EpTEST_Sh01
Looks like after name has got time is doubled. I should go deeper and find out how to optimize all this.
Code from file_checkin.py
Code i run to test:
Results:
(0.009768962860107422, '**************************************************', 'STARTING')
(0.016762971878051758, '**************************************************', 'CREATED FILE OBJECT')
(0.02452397346496582, '**************************************************', 'GOT FILE NAMING')
(0.12882614135742188, '**************************************************', 'GOT FILE NAME', u'EpTEST_Sh01_animation_v001')
(0.12989497184753418, '**************************************************', 'GOT DIRS')
(0.18693208694458008, '**************************************************', 'GOR LIB DIR', u'/home/apache/assets/dolly3d/episodes/EpTEST/animation/versions')
client_repo
(0.25337696075439453, '**************************************************', 'GOT REPOS', u'/home/apache/assets/dolly3d/episodes/EpTEST/animation/versions')
/home/apache/assets/dolly3d/episodes/EpTEST/animation/versions/EpTEST_Sh01_animation_v001
(0.0014290809631347656, '**************************************************', 'STARTING')
(0.0025000572204589844, '**************************************************', 'CREATED FILE OBJECT')
(0.003049135208129883, '**************************************************', 'GOT FILE NAMING')
(0.03217816352844238, '**************************************************', 'GOT FILE NAME', u'EpTEST_Sh01')
(0.03326010704040527, '**************************************************', 'GOT DIRS')
(0.08859395980834961, '**************************************************', 'GOR LIB DIR', u'/home/apache/assets/dolly3d/episodes/EpTEST')
client_repo
(0.1293330192565918, '**************************************************', 'GOT REPOS', u'/home/apache/assets/dolly3d/episodes/EpTEST')
/home/apache/assets/dolly3d/episodes/EpTEST/EpTEST_Sh01
Looks like after name has got time is doubled. I should go deeper and find out how to optimize all this.
Code from file_checkin.py
Code:
def get_preallocated_path(cls, snapshot, file_type='main', file_name='', file_range='', mkdir=True, protocol=None, ext='', parent=None, checkin_type=''):
import time
start_time = time.time()
# we need a dummy file_code and range
#file_code = '123UNI'
#if not file_range:
# file_range = "1-30"
if not parent:
parent = snapshot.get_parent()
assert parent
if not file_name:
file_name = parent.get_code()
if not file_name:
file_name = parent.get_name()
if not file_name:
file_name = "unknown"
print(time.time() - start_time, '*'*50, 'STARTING')
file_object = SearchType.create("sthpw/file")
file_object.set_value("file_name", file_name)
file_object.set_value("type", file_type)
#file_object.set_value("code", file_code)
#file_object.set_value("range", file_range)
print(time.time() - start_time, '*' * 50, 'CREATED FILE OBJECT')
# build the file name
file_naming = Project.get_file_naming()
file_naming.set_sobject(parent)
file_naming.set_snapshot(snapshot)
file_naming.set_file_object(file_object)
file_naming.set_ext(ext)
print(time.time() - start_time, '*' * 50, 'GOT FILE NAMING')
file_name = file_naming.get_file_name()
print(time.time() - start_time, '*' * 50, 'GOT FILE NAME', file_name)
# update the file_name of the file_object from file_naming
file_object.set_value("file_name", file_name)
context = snapshot.get_context()
process = snapshot.get_process()
if not process:
process = context
# assume is_revision = False
return_data = cls.process_checkin_type(checkin_type, parent, process,\
context , file_name, snapshot.get_value('snapshot_type'))
dir_naming = return_data.get('dir_naming')
file_naming = return_data.get('file_naming')
print(time.time() - start_time, '*' * 50, 'GOT DIRS')
lib_dir = snapshot.get_lib_dir(file_type=file_type, create=True, file_object=file_object, dir_naming=dir_naming)
if mkdir and not os.path.exists(lib_dir):
System().makedirs(lib_dir)
print(time.time() - start_time, '*' * 50, 'GOR LIB DIR', lib_dir)
print protocol
# get the client lib dir
if protocol == "client_repo":
client_lib_dir = snapshot.get_client_lib_dir(file_type=file_type, create=True, file_object=file_object, dir_naming=dir_naming)
elif protocol =='sandbox':
client_lib_dir = snapshot.get_sandbox_dir(file_type=file_type)
else:
client_lib_dir = snapshot.get_lib_dir(file_type=file_type, create=True, file_object=file_object, dir_naming=dir_naming)
print(time.time() - start_time, '*' * 50, 'GOT REPOS', client_lib_dir)
# put some protection in for ending slash
client_lib_dir = client_lib_dir.rstrip("/")
path = "%s/%s" % (client_lib_dir, file_name)
print path
return path
get_preallocated_path = classmethod(get_preallocated_path)
Code i run to test:
Code:
import time
import json
start_time = time.time()
server.set_project('dolly3d')
results_dict = {}
results_list = []
preallocated_path = server.get_virtual_snapshot_path('complex/shot?project=dolly3d&code=SHOT00646', 'animation')
results_dict['preallocated_path'] = time.time() - start_time
results_list.append(preallocated_path)
virtual_snapshot = server.get_preallocated_path('SNAPSHOT00009768', mkdir=False)
results_dict['virtual_snapshot'] = time.time() - start_time
results_list.append(virtual_snapshot)
results_dict['result'] = results_list
return json.dumps(results_dict)