- Benchee.run(%{
- "Rendering home timeline" => fn ->
- Pleroma.Web.MastodonAPI.StatusView.render("index.json", %{
- activities: home_activities,
- for: user,
- as: :activity
- })
- end,
- "Rendering public timeline" => fn ->
- Pleroma.Web.MastodonAPI.StatusView.render("index.json", %{
- activities: public_activities,
- for: user,
- as: :activity
- })
- end,
- "Rendering public federated timeline" => fn ->
- Pleroma.Web.MastodonAPI.StatusView.render("index.json", %{
- activities: public_federated_activities,
- for: user,
- as: :activity
- })
- end
- })
- end
-
- def query_notifications(user) do
- without_muted_params = %{"count" => "20", "with_muted" => "false"}
- with_muted_params = %{"count" => "20", "with_muted" => "true"}
-
- Benchee.run(%{
- "Notifications without muted" => fn ->
- Pleroma.Web.MastodonAPI.MastodonAPI.get_notifications(user, without_muted_params)
- end,
- "Notifications with muted" => fn ->
- Pleroma.Web.MastodonAPI.MastodonAPI.get_notifications(user, with_muted_params)
- end
- })
-
- without_muted_notifications =
- Pleroma.Web.MastodonAPI.MastodonAPI.get_notifications(user, without_muted_params)
-
- with_muted_notifications =
- Pleroma.Web.MastodonAPI.MastodonAPI.get_notifications(user, with_muted_params)
-
- Benchee.run(%{
- "Render notifications without muted" => fn ->
- Pleroma.Web.MastodonAPI.NotificationView.render("index.json", %{
- notifications: without_muted_notifications,
- for: user
- })
- end,
- "Render notifications with muted" => fn ->
- Pleroma.Web.MastodonAPI.NotificationView.render("index.json", %{
- notifications: with_muted_notifications,
- for: user
- })
- end
- })
- end
-
- def query_dms(user) do
- params = %{
- "count" => "20",
- "with_muted" => "true",
- "type" => "Create",
+ defp fetch_public_timeline(user, :local) do
+ opts = opts_for_public_timeline(user, :local)
+
+ fetch_public_timeline(opts, "public timeline only local")
+ end
+
+ defp fetch_public_timeline(user, :tag) do
+ opts = opts_for_public_timeline(user, :tag)
+
+ fetch_public_timeline(opts, "hashtag timeline")
+ end
+
+ defp fetch_public_timeline(user, :only_media) do
+ opts = opts_for_public_timeline(user) |> Map.put("only_media", "true")
+
+ fetch_public_timeline(opts, "public timeline only media")
+ end
+
+ defp fetch_public_timeline(opts, title) when is_binary(title) do
+ first_page_last = ActivityPub.fetch_public_activities(opts) |> List.last()
+
+ second_page_last =
+ ActivityPub.fetch_public_activities(Map.put(opts, "max_id", first_page_last.id))
+ |> List.last()
+
+ third_page_last =
+ ActivityPub.fetch_public_activities(Map.put(opts, "max_id", second_page_last.id))
+ |> List.last()
+
+ forth_page_last =
+ ActivityPub.fetch_public_activities(Map.put(opts, "max_id", third_page_last.id))
+ |> List.last()
+
+ Benchee.run(
+ %{
+ title => fn opts ->
+ ActivityPub.fetch_public_activities(opts)
+ end
+ },
+ inputs: %{
+ "1 page" => opts,
+ "2 page" => Map.put(opts, "max_id", first_page_last.id),
+ "3 page" => Map.put(opts, "max_id", second_page_last.id),
+ "4 page" => Map.put(opts, "max_id", third_page_last.id),
+ "5 page" => Map.put(opts, "max_id", forth_page_last.id)
+ },
+ formatters: formatters()
+ )
+ end
+
+ defp opts_for_notifications do
+ %{"count" => "20", "with_muted" => "true"}
+ end
+
+ defp fetch_notifications(user) do
+ opts = opts_for_notifications()
+
+ first_page_last = MastodonAPI.get_notifications(user, opts) |> List.last()
+
+ second_page_last =
+ MastodonAPI.get_notifications(user, Map.put(opts, "max_id", first_page_last.id))
+ |> List.last()
+
+ third_page_last =
+ MastodonAPI.get_notifications(user, Map.put(opts, "max_id", second_page_last.id))
+ |> List.last()
+
+ forth_page_last =
+ MastodonAPI.get_notifications(user, Map.put(opts, "max_id", third_page_last.id))
+ |> List.last()
+
+ Benchee.run(
+ %{
+ "Notifications" => fn opts ->
+ MastodonAPI.get_notifications(user, opts)
+ end
+ },
+ inputs: %{
+ "1 page" => opts,
+ "2 page" => Map.put(opts, "max_id", first_page_last.id),
+ "3 page" => Map.put(opts, "max_id", second_page_last.id),
+ "4 page" => Map.put(opts, "max_id", third_page_last.id),
+ "5 page" => Map.put(opts, "max_id", forth_page_last.id)
+ },
+ formatters: formatters()
+ )
+ end
+
+ defp fetch_favourites(user) do
+ first_page_last = ActivityPub.fetch_favourites(user) |> List.last()
+
+ second_page_last =
+ ActivityPub.fetch_favourites(user, %{"max_id" => first_page_last.id}) |> List.last()
+
+ third_page_last =
+ ActivityPub.fetch_favourites(user, %{"max_id" => second_page_last.id}) |> List.last()
+
+ forth_page_last =
+ ActivityPub.fetch_favourites(user, %{"max_id" => third_page_last.id}) |> List.last()
+
+ Benchee.run(
+ %{
+ "Favourites" => fn opts ->
+ ActivityPub.fetch_favourites(user, opts)
+ end
+ },
+ inputs: %{
+ "1 page" => %{},
+ "2 page" => %{"max_id" => first_page_last.id},
+ "3 page" => %{"max_id" => second_page_last.id},
+ "4 page" => %{"max_id" => third_page_last.id},
+ "5 page" => %{"max_id" => forth_page_last.id}
+ },
+ formatters: formatters()
+ )
+ end
+
+ defp opts_for_long_thread(user) do
+ %{