A framework that aims to achieve interoperability between software such as simulation engines, databases and data repositories using a knowledge graph as the common language.
Simple fix to the performance problem explained below.
Consider the following code snippets, labeled as slow code and fast code.
Slow code
from osp.core.namespaces import mechanical as mt
from osp.core.namespaces import math, metrology
from osp.core.namespaces import properties as prop
from time import time
from tqdm import tqdm
n = (333636 // 3)
start = time()
for i in tqdm(range(0, n)):
bending_stiffness_average_value = 0.0312 # some numerical value
cableSystem = mt.CableBundle()
bendingStiffness_average = mt.BendingStiffness()
realNumber = math.Real(hasNumericalData=bending_stiffness_average_value)
bendingStiffness_average.add(realNumber, rel=metrology.hasQuantityValue)
cableSystem.add(bendingStiffness_average, rel=prop.hasProperty)
end = time()
print("time %.2f" % (end - start))
Fast code
from osp.core.namespaces import mechanical as mt
from osp.core.namespaces import math, metrology
from osp.core.namespaces import properties as prop
from time import time
from tqdm import tqdm
n = (333636 // 3)
start = time()
# Expensive calls below
cable_bundle_class = mt.CableBundle
bending_stiffness_class = mt.BendingStiffness
real_class = math.Real
rel1 = metrology.hasQuantityValue
rel2 = prop.hasProperty
# Expensive calls above
for i in tqdm(range(0, n)):
bending_stiffness_average_value = 0.0312 # some numerical value
cableSystem = cable_bundle_class()
bendingStiffness_average = bending_stiffness_class()
realNumber = real_class(hasNumericalData=bending_stiffness_average_value)
bendingStiffness_average.add(realNumber, rel=rel1)
cableSystem.add(bendingStiffness_average, rel=rel2)
end = time()
print("time %.2f" % (end - start))
Estimation given by tqdm for each code snippet without this fix:
slow code: 134/111212 [00:14<3:24:00, 9.07it/s]
fast code: 2117/111212 [00:09<07:46, 234.05it/s]
Estimation given by tqdm for each code snippet with this fix:
Simple fix to the performance problem explained below.
Consider the following code snippets, labeled as slow code and fast code.
Slow code
Fast code
Estimation given by tqdm for each code snippet without this fix:
134/111212 [00:14<3:24:00, 9.07it/s]
2117/111212 [00:09<07:46, 234.05it/s]
Estimation given by tqdm for each code snippet with this fix:
2099/111212 [00:07<06:39, 272.89it/s]
2130/111212 [00:07<06:35, 276.00it/s]