Skip to content

An Elixir wrapper around :timer.tc but on steroids

License

Notifications You must be signed in to change notification settings

lorenzosinisi/duration

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Duration, a wrapper around :timer.tc of Erlang but in Elixir

I found myself having to monitor the duration of time it took to execute some code in Elixir project but I also wanted to humanized version of that duration of time. So I build a wrapper utility module that can do that for me in every project without having to duplicate code everywhere.

It uses Timex to output the time it took to execute a function in both milliseconds and a humanized way.

Example:

iex(1)> Timer.tc(fn -> :timer.sleep(:timer.seconds(1)) end)
[time: 1002248, humanized_duration: "1 second, 2.248 milliseconds", reply: :ok]

Installation

If available in Hex, the package can be installed by adding duration to your list of dependencies in mix.exs:

def deps do
  [
    {:duration, "~> 0.1.0"}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/duration.

About

An Elixir wrapper around :timer.tc but on steroids

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages