bencheeorg / bencheeorg/benchee

Units: Use `use` to simplify implementing units

Open
#155 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Elixir
Stars
1.5k
Forks
70
PR merge metrics
No merged PRs in 30d

Description

The unit implementations have a lot of method definitions that an implementation needs to define but that definitely just call out to a more common for code sharing.

For instance:

```elixir
def scale(count, unit) do
Scale.scale count, unit, __MODULE__
end
```

if we implemented that functionality inside a `__using__` definitions of those functions are unnecessary, leading to more concise unit definitions. A smaller example of this is implemented in #154

[genserver does the same](https://github.com/elixir-lang/elixir/blob/v1.3.0-rc.0/lib/elixir/lib/gen_server.ex#L437-L482) - well more or less. Difference is, we don't want the functions to be overridden as far as I can tell.

Downsides of this approach I see so far:

* magic :star2:
* I think the documenation of the methods that are defined "commonly" will be the same for all modules. Not really a "big" problem, but that means the iex usage examples/doctests will always contain examples of the other units (or none at all)

I think it should considerably shrink down the effort to implement new units so I think it'd be good. Interested to see what others think ( @wasnotrice since you did the first version here)

Not high priority, as it'd be pure refactoring

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.