Skip to content

Add computation time#2209

Merged
visr merged 1 commit intomainfrom
time
Apr 5, 2025
Merged

Add computation time#2209
visr merged 1 commit intomainfrom
time

Conversation

@visr
Copy link
Member

@visr visr commented Apr 4, 2025

Fixes #2207. This logs the computation time:

┌ Info: Starting a Ribasim simulation.
│   toml_path = "models\\hws\\hws_2025_3_0\\hws.toml"
│   cli.ribasim_version = "2025.2.0"
│   starttime = 2023-01-20T00:00:00
└   endtime = 2024-04-27T00:00:00
Simulating 100%|███████████████████████████████████████████████████████████████████████████████| Time: 0:00:50
[ Info: Computation time: 49 seconds, 955 milliseconds

The time is also at the end of the progress bar, but this bar is not logged to ribasim.log so there was no record of it there.

There is also a new column computation_time in solver_stats.arrow, with the time in milliseconds for that period. I went for millisecond since the order of seconds per day is only really applicable for very large models.

In [1]: import pandas as pd

In [2]: df = pd.read_feather("solver_stats.arrow")

In [3]: df
Out[3]:
          time  computation_time  rhs_calls  linear_solves  accepted_timesteps  rejected_timesteps
0   2023-01-20         2244.7489       7712           7709                2850                 458
1   2023-01-21          632.4497       2513           2513                 737                 128
2   2023-01-22          164.0670        662            662                 195                  36
3   2023-01-23          387.5130       1428           1428                 402                  80
4   2023-01-24          190.5293        751            751                 214                  37
..         ...               ...        ...            ...                 ...                 ...
458 2024-04-22          132.2348        542            542                  67                   6
459 2024-04-23          181.5635        703            703                  64                  10
460 2024-04-24           67.9207        292            292                  32                   2
461 2024-04-25          117.8029        451            451                  30                   8
462 2024-04-26            5.1752         16             16                   7                   0

[463 rows x 6 columns]

In [4]: df["computation_time"].sum() / 1000
Out[4]: np.float64(50.0540202)

Copy link
Member

@evetion evetion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A nice and small (efficient!) PR

end
check_error!(integrator)
comptime = canonicalize(Millisecond(round(Int, comptime_s * 1000)))
@info "Computation time: $comptime"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It this captured by our logging system (and thus ends up in the log file)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I checked. And there are tests for this for other log messages.

@visr visr merged commit 2bbd7c1 into main Apr 5, 2025
20 checks passed
@visr visr deleted the time branch April 5, 2025 19:16
visr added a commit that referenced this pull request Apr 15, 2025
## [v2025.3.0] - 2025-04-14

The only breaking change in this release is to disallow connecting a
single FlowBoundary to multiple Basins.
There are large improvements in the ability to visualize results on the
map in QGIS.
We also welcome the Junction node to the family, which will help laying
out networks in a recognizable manner.

### Added
- Add spatio-temporal results layers to QGIS.
[#2208](#2208)
- Add topological (straight line) link view toggle to QGIS.
[#2208](#2208)
- Added [Junction](https://ribasim.org/reference/node/junction.html)
node type. [#2175](#2175)
- Write results and log bottlenecks also on an interrupt or crash.
[#2191](#2191)
[#2200](#2200)
- Log computation time and save it to `solver_stats.arrow`.
[#2209](https://github.com/Deltares/Ribasim/pull/)
- Experimental support for writing the model network and results into
files used by Delft-FEWS,
[`model.to_fews`](`https://ribasim.org/reference/python/Model.html#ribasim.Model.to_fews`).
[#2161](#2161)
- Document
[`results/concentration.arrow`](https://ribasim.org/reference/usage.html#concentration---concentration.arrow).
[#2165](#2165)

### Changed
- Allow max 1 outflow neighbour for FlowBoundary.
[#2192](#2192)
- Automatic differentiation is enabled by default again, `autodiff =
true`, leading to better performance.
[#2137](#2137)
[#2183](#2183)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Record the time to simulate

2 participants