Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- defmodule Builder.LinkBench do
- alias JaSerializer.Builder.Link
- use Benchfella
- @template %Link.Compiled{template: "/widget/~s", meths: [:id]}
- bench "with a binary",
- [context: context()],
- do: Link.build(context, :related, "/widget/:id")
- bench "with an atom",
- [context: context()],
- do: Link.build(context, :related, :id_href)
- bench "with a compiled template",
- [context: context()],
- do: Link.build(context, :related, @template)
- defmodule Serializer do
- def id(%{id: id}, _), do: id
- def id_href(%{id: id}, _), do: "/widget/#{id}"
- end
- defp context, do: %{serializer: Serializer, data: %{id: 1}, conn: nil}
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement