forked from thechangelog/changelog.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.iex.exs
27 lines (22 loc) · 763 Bytes
/
.iex.exs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
alias Changelog.{Buffer, Repo, Person, Episode, EpisodeHost, EpisodeGuest, Github,
NewsAd, NewsItem, NewsItemComment, NewsSource, NewsSponsorship,
NewsQueue, Podcast, Post, Sponsor, Subscription, Topic}
import Ecto
import Ecto.Changeset
import Ecto.Query, only: [from: 1, from: 2]
defmodule Benchmark do
def measure(function) do
function
|> :timer.tc
|> elem(0)
|> Kernel./(1_000_000)
end
end
defmodule H do
def get(Episode, id), do: Repo.get(Episode, id) |> Repo.preload(:podcast)
def get(model, id), do: Repo.get(model, id)
def update(model, id, attrs \\ %{}) do
Repo.update Ecto.Changeset.change(Repo.get(model, id), attrs)
end
def delete(model, id), do: Repo.delete get(model, id)
end