defmodule Mix.Tasks.Pleroma.Benchmarks.Tags do
use Mix.Task
- alias Pleroma.Repo
- alias Pleroma.LoadTesting.Generator
+
+ import Pleroma.LoadTesting.Helper, only: [clean_tables: 0]
import Ecto.Query
+ alias Pleroma.Repo
+ alias Pleroma.Web.MastodonAPI.TimelineController
+
def run(_args) do
Mix.Pleroma.start_pleroma()
activities_count = Repo.aggregate(from(a in Pleroma.Activity), :count, :id)
if activities_count == 0 do
IO.puts("Did not find any activities, cleaning and generating")
clean_tables()
- Generator.generate_users(users_max: 10)
- Generator.generate_tagged_activities()
+ Pleroma.LoadTesting.Users.generate_users(10)
+ Pleroma.LoadTesting.Activities.generate_tagged_activities()
else
IO.puts("Found #{activities_count} activities, won't generate new ones")
end
Benchee.run(
%{
"Hashtag fetching, any" => fn tags ->
- Pleroma.Web.MastodonAPI.TimelineController.hashtag_fetching(
+ TimelineController.hashtag_fetching(
%{
"any" => tags
},
end,
# Will always return zero results because no overlapping hashtags are generated.
"Hashtag fetching, all" => fn tags ->
- Pleroma.Web.MastodonAPI.TimelineController.hashtag_fetching(
+ TimelineController.hashtag_fetching(
%{
"all" => tags
},
Benchee.run(
%{
"Hashtag fetching" => fn tag ->
- Pleroma.Web.MastodonAPI.TimelineController.hashtag_fetching(
+ TimelineController.hashtag_fetching(
%{
"tag" => tag
},
time: 5
)
end
-
- defp clean_tables do
- IO.puts("Deleting old data...\n")
- Ecto.Adapters.SQL.query!(Repo, "TRUNCATE users CASCADE;")
- Ecto.Adapters.SQL.query!(Repo, "TRUNCATE activities CASCADE;")
- Ecto.Adapters.SQL.query!(Repo, "TRUNCATE objects CASCADE;")
- end
end