diff options
author | lain <lain@soykaf.club> | 2020-06-05 16:53:56 +0200 |
---|---|---|
committer | lain <lain@soykaf.club> | 2020-06-05 16:53:56 +0200 |
commit | a8ca030d85368285af1b960e14dab5b847ecb35a (patch) | |
tree | 5d8c8922eea940f455946435c073d534df1dec57 /benchmarks/load_testing/fetcher.ex | |
parent | 115d08a7542b92c5e1d889da41c0ee6837a1235e (diff) | |
parent | 657e1583f8af1ecdf218ba283de4234233bfe5fd (diff) | |
download | pleroma-a8ca030d85368285af1b960e14dab5b847ecb35a.tar.gz |
Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into remake-remodel-dms
Diffstat (limited to 'benchmarks/load_testing/fetcher.ex')
-rw-r--r-- | benchmarks/load_testing/fetcher.ex | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/benchmarks/load_testing/fetcher.ex b/benchmarks/load_testing/fetcher.ex index 0de4924bc..22a06e472 100644 --- a/benchmarks/load_testing/fetcher.ex +++ b/benchmarks/load_testing/fetcher.ex @@ -36,6 +36,7 @@ defmodule Pleroma.LoadTesting.Fetcher do fetch_home_timeline(user) fetch_direct_timeline(user) fetch_public_timeline(user) + fetch_public_timeline(user, :with_blocks) fetch_public_timeline(user, :local) fetch_public_timeline(user, :tag) fetch_notifications(user) @@ -227,6 +228,58 @@ defmodule Pleroma.LoadTesting.Fetcher do fetch_public_timeline(opts, "public timeline only media") end + defp fetch_public_timeline(user, :with_blocks) do + opts = opts_for_public_timeline(user) + + remote_non_friends = Agent.get(:non_friends_remote, & &1) + + Benchee.run(%{ + "public timeline without blocks" => fn -> + ActivityPub.fetch_public_activities(opts) + end + }) + + Enum.each(remote_non_friends, fn non_friend -> + {:ok, _} = User.block(user, non_friend) + end) + + user = User.get_by_id(user.id) + + opts = Map.put(opts, "blocking_user", user) + + Benchee.run( + %{ + "public timeline with user block" => fn -> + ActivityPub.fetch_public_activities(opts) + end + }, + ) + + domains = + Enum.reduce(remote_non_friends, [], fn non_friend, domains -> + {:ok, _user} = User.unblock(user, non_friend) + %{host: host} = URI.parse(non_friend.ap_id) + [host | domains] + end) + + domains = Enum.uniq(domains) + + Enum.each(domains, fn domain -> + {:ok, _} = User.block_domain(user, domain) + end) + + user = User.get_by_id(user.id) + opts = Map.put(opts, "blocking_user", user) + + Benchee.run( + %{ + "public timeline with domain block" => fn opts -> + ActivityPub.fetch_public_activities(opts) + end + } + ) + end + defp fetch_public_timeline(opts, title) when is_binary(title) do first_page_last = ActivityPub.fetch_public_activities(opts) |> List.last() |