Skip to content

Commit c7746dd

Browse files
add timelog
1 parent 4c3c154 commit c7746dd

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

generate_database.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ function main()
8686

8787
@info "Calculating low ℓ MQDT states..."
8888
models = MODELS_TABLE[species]
89-
@time states = [eigenstates(n_min, n_max, M, parameters) for M in models]
89+
@timelog states = [eigenstates(n_min, n_max, M, parameters) for M in models]
9090

9191
if args["skip-high-l"]
9292
@info "Skipping high ℓ states."
@@ -95,7 +95,7 @@ function main()
9595
l_max = n_max - 1
9696
l_start = FMODEL_MAX_L[species] + 1
9797
high_l_models = single_channel_models(l_start:l_max, parameters)
98-
@time high_l_states =
98+
@timelog high_l_states =
9999
[eigenstates(n_min, n_max, M, parameters) for M in high_l_models]
100100
states = vcat(states, high_l_states)
101101
models = vcat(models, high_l_models)
@@ -106,7 +106,7 @@ function main()
106106
@info "Generated state table with $(nrow(state_table)) states"
107107

108108
@info "Calculating matrix elements..."
109-
@time row_col_value_dict = all_matrix_element(basis, parameters)
109+
@timelog row_col_value_dict = all_matrix_element(basis, parameters)
110110

111111
@info "Converting matrix elements to database table..."
112112
m1 = rcv_to_df(row_col_value_dict["dipole"])
@@ -129,7 +129,7 @@ function main()
129129
for (name, table) in tables
130130
@info "$(table.desc) info" rows=nrow(table.data)
131131
@info describe(table.data)
132-
@time Parquet2.writefile("$(output_dir)/$(name).parquet", table.data)
132+
@timelog Parquet2.writefile("$(output_dir)/$(name).parquet", table.data)
133133
end
134134

135135
elapsed_time = round(time() - start_time, digits = 2)

utils.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
import MQDT
22

3+
4+
macro timelog(expr)
5+
quote
6+
local result, elapsed_time, bytes_allocated, gc_time, memory_counters = @timed $(esc(expr))
7+
@info "$(round(elapsed_time, digits=6)) seconds (allocations: $(Base.format_bytes(bytes_allocated)), $(round(100 * gc_time / elapsed_time, digits=2))% gc time)"
8+
result
9+
end
10+
end
11+
12+
313
function all_matrix_element(B::BasisArray, parameters::MQDT.Parameters)
414
"""Calculate all relevant matrix elements for a given basis array B.
515

0 commit comments

Comments
 (0)