summaryrefslogtreecommitdiff
path: root/benchmarks/mix/tasks
diff options
context:
space:
mode:
authorAlexander Strizhakov <alex.strizhakov@gmail.com>2020-02-18 12:19:10 +0300
committerAlexander Strizhakov <alex.strizhakov@gmail.com>2020-03-30 11:42:25 +0300
commit1f29ecdcd7ecdc4ad8d6bc8fc4c34efbc9b7fe1d (patch)
treefbf9755e8d2a060205ef21511f8d1dc9fe4694b3 /benchmarks/mix/tasks
parenteb9744cadea7191b088ddaadfbd5fa4d4fd45090 (diff)
downloadpleroma-1f29ecdcd7ecdc4ad8d6bc8fc4c34efbc9b7fe1d.tar.gz
pleroma-1f29ecdcd7ecdc4ad8d6bc8fc4c34efbc9b7fe1d.zip
sync with develop
Diffstat (limited to 'benchmarks/mix/tasks')
-rw-r--r--benchmarks/mix/tasks/pleroma/benchmarks/tags.ex24
-rw-r--r--benchmarks/mix/tasks/pleroma/load_testing.ex10
2 files changed, 11 insertions, 23 deletions
diff --git a/benchmarks/mix/tasks/pleroma/benchmarks/tags.ex b/benchmarks/mix/tasks/pleroma/benchmarks/tags.ex
index fd1506907..657403202 100644
--- a/benchmarks/mix/tasks/pleroma/benchmarks/tags.ex
+++ b/benchmarks/mix/tasks/pleroma/benchmarks/tags.ex
@@ -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
diff --git a/benchmarks/mix/tasks/pleroma/load_testing.ex b/benchmarks/mix/tasks/pleroma/load_testing.ex
index 262300990..72b225f09 100644
--- a/benchmarks/mix/tasks/pleroma/load_testing.ex
+++ b/benchmarks/mix/tasks/pleroma/load_testing.ex
@@ -1,8 +1,8 @@
defmodule Mix.Tasks.Pleroma.LoadTesting do
use Mix.Task
import Ecto.Query
+ import Pleroma.LoadTesting.Helper, only: [clean_tables: 0]
- alias Ecto.Adapters.SQL
alias Pleroma.Repo
alias Pleroma.User
@@ -63,12 +63,4 @@ defmodule Mix.Tasks.Pleroma.LoadTesting do
Pleroma.LoadTesting.Fetcher.run_benchmarks(user)
end
-
- defp clean_tables do
- IO.puts("Deleting old data...\n")
- SQL.query!(Repo, "TRUNCATE users CASCADE;")
- SQL.query!(Repo, "TRUNCATE activities CASCADE;")
- SQL.query!(Repo, "TRUNCATE objects CASCADE;")
- SQL.query!(Repo, "TRUNCATE oban_jobs CASCADE;")
- end
end