-
-
Notifications
You must be signed in to change notification settings - Fork 236
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improvement: don't start processes for single items in list
chore: add some benchmarks/flame files
- Loading branch information
1 parent
e200b5b
commit ce5c080
Showing
11 changed files
with
310 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
defmodule Domain do | ||
use Ash.Domain, validate_config_inclusion?: false | ||
|
||
resources do | ||
allow_unregistered? true | ||
end | ||
end | ||
|
||
defmodule Destination do | ||
use Ash.Resource, | ||
data_layer: Ash.DataLayer.Ets, | ||
domain: Domain | ||
|
||
actions do | ||
defaults [:read, :destroy, create: :*, update: :*] | ||
end | ||
|
||
attributes do | ||
uuid_primary_key :id | ||
attribute :name, :string, allow_nil?: false, public?: true | ||
end | ||
|
||
relationships do | ||
belongs_to :source, Source, public?: true | ||
end | ||
end | ||
|
||
defmodule Source do | ||
use Ash.Resource, | ||
data_layer: Ash.DataLayer.Ets, | ||
domain: Domain | ||
|
||
actions do | ||
defaults [:read, :destroy, create: :*, update: :*] | ||
end | ||
|
||
attributes do | ||
uuid_primary_key :id | ||
attribute :first_name, :string, allow_nil?: false, public?: true | ||
attribute :last_name, :string, allow_nil?: false, public?: true | ||
end | ||
|
||
calculations do | ||
calculate :full_name, :string, expr(first_name <> " " <> last_name) | ||
end | ||
|
||
aggregates do | ||
first :first_destination_name, :destination, :name | ||
end | ||
|
||
relationships do | ||
has_many :destination, Destination | ||
end | ||
end | ||
|
||
source = | ||
Source | ||
|> Ash.Changeset.for_create(:create, %{first_name: "John", last_name: "Doe"}) | ||
|> Ash.create!() | ||
|
||
for _ <- 1..2 do | ||
Destination | ||
|> Ash.Changeset.for_create(:create, %{source_id: source.id, name: "Destination"}) | ||
|> Ash.create!() | ||
end | ||
|
||
query = | ||
Source | ||
|> Ash.Query.for_read(:read, %{}) | ||
|> Ash.Query.load([:first_destination_name, :full_name, :destination]) | ||
|
||
Ash.read!(query) | ||
|
||
Logger.configure(level: :error) | ||
|
||
Benchee.run(%{ | ||
"read" => fn -> | ||
Ash.read!(query) | ||
end | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
Benchee.run( | ||
%{ | ||
"uuid_v7 raw" => fn -> | ||
Ash.UUIDv7.bingenerate() | ||
end, | ||
"uuid_v7 string" => fn -> | ||
Ash.UUIDv7.generate() | ||
end, | ||
"uuid_v4 string" => fn -> | ||
Ash.UUID.generate() | ||
end | ||
Benchee.run(%{ | ||
"uuid_v7 raw" => fn -> | ||
Ash.UUIDv7.bingenerate() | ||
end, | ||
"uuid_v7 string" => fn -> | ||
Ash.UUIDv7.generate() | ||
end, | ||
"uuid_v4 string" => fn -> | ||
Ash.UUID.generate() | ||
end | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
defmodule Domain do | ||
use Ash.Domain, validate_config_inclusion?: false | ||
|
||
resources do | ||
allow_unregistered? true | ||
end | ||
end | ||
|
||
defmodule Destination do | ||
use Ash.Resource, | ||
data_layer: Ash.DataLayer.Ets, | ||
domain: Domain | ||
|
||
actions do | ||
defaults [:read, :destroy, create: :*, update: :*] | ||
end | ||
|
||
attributes do | ||
uuid_primary_key :id | ||
attribute :name, :string, allow_nil?: false, public?: true | ||
end | ||
|
||
relationships do | ||
belongs_to :source, Source, public?: true | ||
end | ||
end | ||
|
||
defmodule Source do | ||
use Ash.Resource, | ||
data_layer: Ash.DataLayer.Ets, | ||
domain: Domain | ||
|
||
actions do | ||
defaults [:read, :destroy, create: :*, update: :*] | ||
end | ||
|
||
attributes do | ||
uuid_primary_key :id | ||
attribute :first_name, :string, allow_nil?: false, public?: true | ||
attribute :last_name, :string, allow_nil?: false, public?: true | ||
end | ||
|
||
calculations do | ||
calculate :full_name, :string, expr(first_name <> " " <> last_name) | ||
end | ||
|
||
aggregates do | ||
first :first_destination_name, :destination, :name | ||
end | ||
|
||
relationships do | ||
has_many :destination, Destination | ||
end | ||
end | ||
|
||
source = | ||
Source | ||
|> Ash.Changeset.for_create(:create, %{first_name: "John", last_name: "Doe"}) | ||
|> Ash.create!() | ||
|
||
for _ <- 1..2 do | ||
Destination | ||
|> Ash.Changeset.for_create(:create, %{source_id: source.id, name: "Destination"}) | ||
|> Ash.create!() | ||
end | ||
|
||
query = | ||
Source | ||
|> Ash.Query.for_read(:read, %{}) | ||
|> Ash.Query.load([:first_destination_name, :full_name, :destination]) | ||
|
||
Ash.read!(query) | ||
|
||
Logger.configure(level: :error) | ||
|
||
:eflame.apply( | ||
fn -> | ||
Ash.read!(query) | ||
end, | ||
[] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.