|
|
|
@ -1,9 +1,12 @@
|
|
|
|
|
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)
|
|
|
|
@ -11,8 +14,8 @@ defmodule Mix.Tasks.Pleroma.Benchmarks.Tags do
|
|
|
|
|
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
|
|
|
|
@ -34,7 +37,7 @@ defmodule Mix.Tasks.Pleroma.Benchmarks.Tags do
|
|
|
|
|
Benchee.run(
|
|
|
|
|
%{
|
|
|
|
|
"Hashtag fetching, any" => fn tags ->
|
|
|
|
|
Pleroma.Web.MastodonAPI.TimelineController.hashtag_fetching(
|
|
|
|
|
TimelineController.hashtag_fetching(
|
|
|
|
|
%{
|
|
|
|
|
"any" => tags
|
|
|
|
|
},
|
|
|
|
@ -44,7 +47,7 @@ defmodule Mix.Tasks.Pleroma.Benchmarks.Tags do
|
|
|
|
|
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
|
|
|
|
|
},
|
|
|
|
@ -64,7 +67,7 @@ defmodule Mix.Tasks.Pleroma.Benchmarks.Tags do
|
|
|
|
|
Benchee.run(
|
|
|
|
|
%{
|
|
|
|
|
"Hashtag fetching" => fn tag ->
|
|
|
|
|
Pleroma.Web.MastodonAPI.TimelineController.hashtag_fetching(
|
|
|
|
|
TimelineController.hashtag_fetching(
|
|
|
|
|
%{
|
|
|
|
|
"tag" => tag
|
|
|
|
|
},
|
|
|
|
@ -77,11 +80,4 @@ defmodule Mix.Tasks.Pleroma.Benchmarks.Tags do
|
|
|
|
|
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
|
|
|
|
|