summaryrefslogtreecommitdiff
path: root/lib/mix/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mix/tasks')
-rw-r--r--lib/mix/tasks/pleroma/load_testing.ex47
1 files changed, 19 insertions, 28 deletions
diff --git a/lib/mix/tasks/pleroma/load_testing.ex b/lib/mix/tasks/pleroma/load_testing.ex
index d17cf0b3e..83e531abf 100644
--- a/lib/mix/tasks/pleroma/load_testing.ex
+++ b/lib/mix/tasks/pleroma/load_testing.ex
@@ -13,46 +13,37 @@ defmodule Mix.Tasks.Pleroma.LoadTesting do
- activities with notifications
## Generate data
- MIX_ENV=test mix pleroma.load_testing --users 10000 --activities 20000
- MIX_ENV=test mix pleroma.load_testing -u 10000 -a 20000
+ MIX_ENV=benchmark mix pleroma.load_testing --users 10000
+ MIX_ENV=benchmark mix pleroma.load_testing -u 10000
Options:
- `--users NUMBER` - number of users to generate (default: 10000)
- - `--activities NUMBER` - number of activities to generate (default: 20000)
"""
- @aliases [u: :users, a: :activities]
+ @aliases [u: :users, d: :dms, t: :thread_length]
@switches [
users: :integer,
- activities: :integer,
dms: :integer,
- thread_length: :integer,
- non_visible_posts: :integer
+ thread_length: :integer
]
@users_default 20_000
- @activities_default 50_000
- @dms_default 50_000
+ @dms_default 20_000
@thread_length_default 2_000
- @non_visible_posts_default 2_000
def run(args) do
start_pleroma()
{opts, _} = OptionParser.parse!(args, strict: @switches, aliases: @aliases)
users_max = Keyword.get(opts, :users, @users_default)
- activities_max = Keyword.get(opts, :activities, @activities_default)
dms_max = Keyword.get(opts, :dms, @dms_default)
- long_thread_length = Keyword.get(opts, :thread_length, @thread_length_default)
- non_visible_posts = Keyword.get(opts, :non_visible_posts, @non_visible_posts_default)
+ thread_length = Keyword.get(opts, :thread_length, @thread_length_default)
clean_tables()
opts =
Keyword.put(opts, :users_max, users_max)
- |> Keyword.put(:activities_max, activities_max)
|> Keyword.put(:dms_max, dms_max)
- |> Keyword.put(:long_thread_length, long_thread_length)
- |> Keyword.put(:non_visible_posts_max, non_visible_posts)
+ |> Keyword.put(:thread_length, thread_length)
generate_users(opts)
@@ -60,7 +51,9 @@ defmodule Mix.Tasks.Pleroma.LoadTesting do
IO.puts("Fetching main user...")
{time, user} =
- :timer.tc(fn -> Repo.one(from(u in User, order_by: fragment("RANDOM()"), limit: 1)) end)
+ :timer.tc(fn ->
+ Repo.one(from(u in User, order_by: fragment("RANDOM()"), limit: 1))
+ end)
IO.puts("Fetching main user take #{to_sec(time)} sec.\n")
@@ -79,25 +72,23 @@ defmodule Mix.Tasks.Pleroma.LoadTesting do
IO.puts("Fetching users take #{to_sec(time)} sec.\n")
- generate_activities(users, opts)
-
- generate_activities(users, Keyword.put(opts, :mention, user))
+ generate_activities(user, users)
generate_dms(user, users, opts)
{:ok, activity} = generate_long_thread(user, users, opts)
- generate_private_thread(users, opts)
+ generate_non_visible_message(user, users)
- # generate_replies(user, users, activities)
+ IO.puts("Users in DB: #{Repo.aggregate(from(u in User), :count, :id)}")
- # activity = Enum.random(activities)
- # generate_long_thread(user, users, activity)
+ IO.puts("Activities in DB: #{Repo.aggregate(from(a in Pleroma.Activity), :count, :id)}")
- IO.puts("Users in DB: #{Repo.aggregate(from(u in User), :count, :id)}")
- IO.puts("Activities in DB: #{Repo.aggregate(from(a in Activity), :count, :id)}")
- IO.puts("Objects in DB: #{Repo.aggregate(from(o in Object), :count, :id)}")
- IO.puts("Notifications in DB: #{Repo.aggregate(from(n in Notification), :count, :id)}")
+ IO.puts("Objects in DB: #{Repo.aggregate(from(o in Pleroma.Object), :count, :id)}")
+
+ IO.puts(
+ "Notifications in DB: #{Repo.aggregate(from(n in Pleroma.Notification), :count, :id)}"
+ )
fetch_user(user)
query_timelines(user)