Zulip Chat Archive
Stream: Is there code for X?
Topic: Timing function executions
Tanner Duve (Aug 14 2024 at 22:43):
Is there a way to output the execution time of a function? Something like #eval perhaps that includes time?
Kim Morrison (Aug 14 2024 at 23:22):
See Mathlib.Util.Time
Kim Morrison (Aug 14 2024 at 23:22):
which provides #time
Kim Morrison (Aug 14 2024 at 23:22):
If you tell me Mathlib is not easily available where you are, I will ask that someone PRs it to lean4, and I will promise to hit merge. :-)
Tanner Duve (Aug 14 2024 at 23:27):
thank you! im working in a large codebase that has had issues every time I've tried to add mathlib to my dependencies and import it. could this be done only in lean4?
Kim Morrison (Aug 14 2024 at 23:50):
Sure, I've been meaning to do this for some time.
Kim Morrison (Aug 14 2024 at 23:51):
(@Mario Carneiro, I'm going to move your #time
command from Mathlib.Util.Time
up to Lean4, assuming that's okay.)
Tanner Duve (Aug 14 2024 at 23:58):
Thanks!
Kim Morrison (Aug 15 2024 at 00:02):
@Tanner Duve, lean#5044.
It should be in nightly-2024-08-15 in about 10 hours, (i.e. you could try replacing the contents of your lean-toolchain
with leanprover/lean4:nightly-2024-08-15
then), and then in v4.12.0-rc2
at the beginning of September.
Kim Morrison (Aug 15 2024 at 00:04):
(If you'd like to describe to me either here or via DM your difficulties resulting from adding mathlib, I'd be interested.)
Tanner Duve (Aug 15 2024 at 00:10):
Thanks I really appreciate it. For adding mathlib, I just followed the directions here for an existing project: https://github.com/leanprover-community/mathlib4/wiki/Using-mathlib4-as-a-dependency. I then try to build my project and the entire thing fails to build with a bunch of error messages. Tried lake clean but same issue.
Tanner Duve (Aug 15 2024 at 17:03):
Hey, wanted to check back in on this. When I replace the contents of lean-toolchain I get the following error:
info: downloading component 'lean'
Error(Download(HttpStatus(404)), State { next_error: None, backtrace: InternalBacktrace { backtrace: None } })
error: could not download nonexistent lean version leanprover/lean4:nightly-2024-08-15
info: caused by: could not download file from 'https://github.com/leanprover/lean4-nightly/releases/expanded_assets/nightly-2024-08-15' to '/Users/tduve/.elan/tmp/v1fx1ugo4bdsy9rd_file'
info: caused by: http request returned an unsuccessful status code: 404
Any idea how to solve this?
Chris Bailey (Aug 15 2024 at 17:12):
Just wait, I think. If I'm reading the original message right, the nightly for 8-15 gets released in ~5 more hours.
Kim Morrison (Aug 15 2024 at 23:16):
Sorry, nightly was delayed yesterday. It usually lands at about .
Eric Wieser (Aug 15 2024 at 23:28):
Tanner Duve said:
I then try to build my project and the entire thing fails to build with a bunch of error messages. Tried lake clean but same issue.
Which Lean toolchain were you using? Note that mathlib isn't really compatible with nightlies without extra steps (choosing the right branch and waiting for Kim to magically fix all the errors).
Last updated: May 02 2025 at 03:31 UTC