docs fixes

This commit is contained in:
Alex S 2019-09-06 16:37:18 +03:00
parent a1125bd564
commit 252e5db45c
3 changed files with 13 additions and 15 deletions

View file

@ -2,8 +2,6 @@ defmodule Pleroma.LoadTesting.Fetcher do
use Pleroma.LoadTesting.Helper use Pleroma.LoadTesting.Helper
def fetch_user(user) do def fetch_user(user) do
IO.puts("=================================")
Benchee.run(%{ Benchee.run(%{
"By id" => fn -> Repo.get_by(User, id: user.id) end, "By id" => fn -> Repo.get_by(User, id: user.id) end,
"By ap_id" => fn -> Repo.get_by(User, ap_id: user.ap_id) end, "By ap_id" => fn -> Repo.get_by(User, ap_id: user.ap_id) end,
@ -13,8 +11,6 @@ def fetch_user(user) do
end end
def query_timelines(user) do def query_timelines(user) do
IO.puts("\n=================================")
home_timeline_params = %{ home_timeline_params = %{
"count" => 20, "count" => 20,
"with_muted" => true, "with_muted" => true,
@ -102,7 +98,6 @@ def query_timelines(user) do
end end
def query_notifications(user) do def query_notifications(user) do
IO.puts("\n=================================")
without_muted_params = %{"count" => "20", "with_muted" => "false"} without_muted_params = %{"count" => "20", "with_muted" => "false"}
with_muted_params = %{"count" => "20", "with_muted" => "true"} with_muted_params = %{"count" => "20", "with_muted" => "true"}
@ -138,8 +133,6 @@ def query_notifications(user) do
end end
def query_dms(user) do def query_dms(user) do
IO.puts("\n=================================")
params = %{ params = %{
"count" => "20", "count" => "20",
"with_muted" => "true", "with_muted" => "true",
@ -187,8 +180,6 @@ def query_dms(user) do
end end
def query_long_thread(user, activity) do def query_long_thread(user, activity) do
IO.puts("\n=================================")
Benchee.run(%{ Benchee.run(%{
"Fetch main post" => fn -> "Fetch main post" => fn ->
Pleroma.Activity.get_by_id_with_object(activity.id) Pleroma.Activity.get_by_id_with_object(activity.id)

View file

@ -28,7 +28,8 @@ defp generate_user_data(i) do
nickname: "nick#{i}", nickname: "nick#{i}",
password_hash: Comeonin.Pbkdf2.hashpwsalt("test"), password_hash: Comeonin.Pbkdf2.hashpwsalt("test"),
bio: "Tester Number #{i}", bio: "Tester Number #{i}",
info: %{} info: %{},
local: Enum.random([true, false])
} }
user = %{ user = %{

View file

@ -5,19 +5,23 @@ defmodule Mix.Tasks.Pleroma.LoadTesting do
import Pleroma.LoadTesting.Generator import Pleroma.LoadTesting.Generator
import Pleroma.LoadTesting.Fetcher import Pleroma.LoadTesting.Fetcher
# tODO: remove autovacuum worker until generation is not ended
@shortdoc "Factory for generation data" @shortdoc "Factory for generation data"
@moduledoc """ @moduledoc """
Generates data like: Generates data like:
- users - users
- activities with notifications - activities with notifications
- direct messages
- long thread
- non visible posts
## Generate data ## Generate data
MIX_ENV=benchmark mix pleroma.load_testing --users 10000 MIX_ENV=benchmark mix pleroma.load_testing --users 20000 --dms 20000 --thread_length 2000
MIX_ENV=benchmark mix pleroma.load_testing -u 10000 MIX_ENV=benchmark mix pleroma.load_testing -u 20000 -d 20000 -t 2000
Options: Options:
- `--users NUMBER` - number of users to generate (default: 10000) - `--users NUMBER` - number of users to generate. Defaults to: 20000. Alias: `-u`
- `--dms NUMBER` - number of direct messages to generate. Defaults to: 20000. Alias `-d`
- `--thread_length` - number of messages in thread. Defaults to: 2000. ALias `-t`
""" """
@aliases [u: :users, d: :dms, t: :thread_length] @aliases [u: :users, d: :dms, t: :thread_length]
@ -32,6 +36,7 @@ defmodule Mix.Tasks.Pleroma.LoadTesting do
def run(args) do def run(args) do
start_pleroma() start_pleroma()
Pleroma.Config.put([:instance, :skip_thread_containment], true)
{opts, _} = OptionParser.parse!(args, strict: @switches, aliases: @aliases) {opts, _} = OptionParser.parse!(args, strict: @switches, aliases: @aliases)
users_max = Keyword.get(opts, :users, @users_default) users_max = Keyword.get(opts, :users, @users_default)
@ -95,11 +100,12 @@ def run(args) do
query_notifications(user) query_notifications(user)
query_dms(user) query_dms(user)
query_long_thread(user, activity) query_long_thread(user, activity)
Pleroma.Config.put([:instance, :skip_thread_containment], false)
query_timelines(user) query_timelines(user)
end end
defp clean_tables do defp clean_tables do
IO.puts("\n\nDeleting old data...\n") IO.puts("Deleting old data...\n")
Ecto.Adapters.SQL.query!(Repo, "TRUNCATE users CASCADE;") Ecto.Adapters.SQL.query!(Repo, "TRUNCATE users CASCADE;")
Ecto.Adapters.SQL.query!(Repo, "TRUNCATE activities CASCADE;") Ecto.Adapters.SQL.query!(Repo, "TRUNCATE activities CASCADE;")
Ecto.Adapters.SQL.query!(Repo, "TRUNCATE objects CASCADE;") Ecto.Adapters.SQL.query!(Repo, "TRUNCATE objects CASCADE;")