Skip to content

Commit

Permalink
2 improve time operators performance (#7)
Browse files Browse the repository at this point in the history
* Improved time operators performance, refactored get_frequencies and find_min_frequency class methods.

* TimeHandling code cleaned.

* TimeHandling exceptions changed to SemanticError exceptions.

* Added new time semantic exception messages.

* Time operators timeshift class optimized.

* re-added old exception messages on TimeHandling.py, minor changes on Time.py.

* Cleaned some imports.

* Cleaned some imports.

* Added flake8 and black.

* Removed flake8 and black from this branch.

* Added usage of map instead of apply in get_frequencies on class Shift_dates.

* New time semantic error messages code changed to 2-1-19-X.

---------

Co-authored-by: Francisco Javier Hernández del Caño <[email protected]>
  • Loading branch information
mla2001 and javihern98 authored Oct 3, 2024
1 parent 2fd53db commit aac7d7f
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 214 deletions.
35 changes: 23 additions & 12 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,33 @@

from vtlengine.API import run

base_path = Path(__file__).parent / 'development' / 'data'
dev_name = 'BOP'
base_path = Path(__file__).parent / 'development' / 'data' / dev_name
input_dp = base_path / 'dataPoints' / 'input'
output_dp = base_path / 'dataPoints' / 'output'
input_ds = base_path / 'dataStructures' / 'input'
ext_routines = base_path / 'externalRoutines'
vds = base_path / 'valueDomains'
vtl = base_path / 'vtl' / 'monthVal.vtl'
vtl = base_path / 'vtl' / f'{dev_name}.vtl'

if __name__ == '__main__':
start = time()
run(
script=vtl,
data_structures=input_ds,
datapoints=input_dp,
value_domains=vds,
output_folder=output_dp,
)
end = time()
print(f"Execution time: {round(end - start, 2)}s")
time_vector = []
num_executions = 3
for i in range(num_executions):
start = time()
run(
script=vtl,
data_structures=input_ds,
datapoints=input_dp,
value_domains=vds,
output_folder=output_dp,
)
end = time()
total_time = round(end - start, 2)
time_vector.append(total_time)
print(f'Execution ({i + 1}/{num_executions}): {total_time}s')
print('-' * 30)
print(f'Average time: {round(sum(time_vector) / num_executions, 2)}s')
print(f'Min time: {min(time_vector)}s')
print(f'Max time: {max(time_vector)}s')
print(f'Total time: {round(sum(time_vector), 2)}s')
Loading

0 comments on commit aac7d7f

Please sign in to comment.