Other alternative is to have a `time` macro that would be similar to the
Unix `time` command. `time/0` would show the execution time of the last
command, and `time expr` would show the execution time of the given
expression.
We would loose discoverability, that's true, but we could list `time/0,1`
in the IEx help (h/0); and we would gain `time expr` which would be easier
to type, remember, and discover than `:timer.tc`, and could have a more
human-readable output.
Thoughts?
On Friday, October 18, 2019 at 9:06:39 AM UTC+2, Fernando Tapia Rico wrote:
>
> Long-running commands could print some traces during execution and return
> a big list of results. If this message is printed in-between, I think it
> will be harder to spot.
>
> On Friday, October 18, 2019 at 9:00:12 AM UTC+2, José Valim wrote:
>>
>> My suggestion is to show it *before* we show the result, this way I don't
>> think we need to include the prompt. +1 no some sort of IEx prefix:
>>
>> iex> long_operation()
>> [iex] command took 12.1s
>> %Some.Struct{...]
>>
>>
>>
>> *José Valim*
>> www.plataformatec.com.br
>> Skype: jv.ptec
>> Founder and Director of R&D
>>
>>
>> On Fri, Oct 18, 2019 at 8:55 AM Fernando Tapia Rico <[email protected]>
>> wrote:
>>
>>> One thing I really like about the automatic message is that it is
>>>> discoverable. The feature is just there. And we have prior art.
>>>
>>>
>>> Agreed.
>>>
>>> And also agree with Ben Wilson on using the `iex` prefix, but I would
>>> include the number of the prompt. Here is a mockup:
>>>
>>> [image: Screen Shot 2019-10-18 at 08.52.29.png]
>>>
>>>
>>> If anyone wants to play a bit with it (more spaces, other message, time
>>> inside the prompt, etc), here is the mockup code:
>>>
>>>
>>> IO.puts("\n\niex(9)> :timer.sleep(32_000)\n" <> IO.ANSI.cyan() <>
>>> ":ok\n" <> IO.ANSI.reset() <> "iex(9) run in 32 seconds\niex(10)> _\n\n"
>>> )
>>>
>>>
>>>
>>>
>>> On Friday, October 18, 2019 at 5:22:55 AM UTC+2, Ben Wilson wrote:
>>>>
>>>> I really like this feature idea. Often you don't know or expect that a
>>>> particular function will take so long, and it's precisely at that point
>>>> that you go "man, I wish I had timed that". Particularly if the function
>>>> is
>>>> doing a side effect, it may be non trivial to try again.
>>>>
>>>> Perhaps if the messaging all happened with the `iex()` prefix it might
>>>> make more sense where it's coming from?
>>>>
>>>> iex(1)> some_long_fun()
>>>> iex(taking more than 5 seconds ...)
>>>> iex(returned after 15 seconds)
>>>> {:ok, :foo}
>>>> iex(2)>
>>>>
>>>> On Thursday, October 17, 2019 at 8:20:16 PM UTC-4, José Valim wrote:
>>>>>
>>>>> Showing the time every time (and other metadata) would definitely be
>>>>> too verbose, even inside the prompt. But I understand the origin of the
>>>>> message being unclear.
>>>>> --
>>>>>
>>>>>
>>>>> *José Valim*
>>>>> www.plataformatec.com.br
>>>>> Skype: jv.ptec
>>>>> Founder and Director of R&D
>>>>>
>>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "elixir-lang-core" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/elixir-lang-core/c4b48de9-7515-4555-ba61-377af0d0233e%40googlegroups.com
>>>
>>> <https://groups.google.com/d/msgid/elixir-lang-core/c4b48de9-7515-4555-ba61-377af0d0233e%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>
--
You received this message because you are subscribed to the Google Groups
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/elixir-lang-core/3f39c47e-b2ad-40c8-b019-d9605d6fff33%40googlegroups.com.