Add benchmark of any/all tag options
authorlain <lain@soykaf.club>
Mon, 20 Jan 2020 11:19:15 +0000 (12:19 +0100)
committerlain <lain@soykaf.club>
Mon, 20 Jan 2020 11:19:15 +0000 (12:19 +0100)
benchmarks/mix/tasks/pleroma/benchmarks/tags.ex

index 73796b5f9d560ecb9f80b80bc9d4d1bec761644d..fd15069073ca6d3e8a7708676a749bc69ff10996 100644 (file)
@@ -31,6 +31,36 @@ defmodule Mix.Tasks.Pleroma.Benchmarks.Tags do
 
     user = Repo.all(Pleroma.User) |> List.first()
 
+    Benchee.run(
+      %{
+        "Hashtag fetching, any" => fn tags ->
+          Pleroma.Web.MastodonAPI.TimelineController.hashtag_fetching(
+            %{
+              "any" => tags
+            },
+            user,
+            false
+          )
+        end,
+        # Will always return zero results because no overlapping hashtags are generated.
+        "Hashtag fetching, all" => fn tags ->
+          Pleroma.Web.MastodonAPI.TimelineController.hashtag_fetching(
+            %{
+              "all" => tags
+            },
+            user,
+            false
+          )
+        end
+      },
+      inputs:
+        tags
+        |> Enum.map(fn {_, v} -> v end)
+        |> Enum.chunk_every(2)
+        |> Enum.map(fn tags -> {"For #{inspect(tags)}", tags} end),
+      time: 5
+    )
+
     Benchee.run(
       %{
         "Hashtag fetching" => fn tag ->