diff options
author | lain <lain@soykaf.club> | 2020-01-15 12:37:50 +0100 |
---|---|---|
committer | lain <lain@soykaf.club> | 2020-01-15 12:37:50 +0100 |
commit | 167e9c45eccf5ddb89077c979b1d587318f78cc0 (patch) | |
tree | d1c5e347cbef51817b4e19b05c1a3c70d025d1ed /lib | |
parent | 2ee6754095f5b81807efe97c73ada42e2c990ede (diff) | |
download | pleroma-167e9c45eccf5ddb89077c979b1d587318f78cc0.tar.gz pleroma-167e9c45eccf5ddb89077c979b1d587318f78cc0.zip |
Benchmarks: Move to correct folder
Diffstat (limited to 'lib')
-rw-r--r-- | lib/mix/tasks/pleroma/benchmarks/tags.ex | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/lib/mix/tasks/pleroma/benchmarks/tags.ex b/lib/mix/tasks/pleroma/benchmarks/tags.ex deleted file mode 100644 index 73796b5f9..000000000 --- a/lib/mix/tasks/pleroma/benchmarks/tags.ex +++ /dev/null @@ -1,57 +0,0 @@ -defmodule Mix.Tasks.Pleroma.Benchmarks.Tags do - use Mix.Task - alias Pleroma.Repo - alias Pleroma.LoadTesting.Generator - import Ecto.Query - - 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() - else - IO.puts("Found #{activities_count} activities, won't generate new ones") - end - - tags = Enum.map(0..20, fn i -> {"For #tag_#{i}", "tag_#{i}"} end) - - Enum.each(tags, fn {_, tag} -> - query = - from(o in Pleroma.Object, - where: fragment("(?)->'tag' \\? (?)", o.data, ^tag) - ) - - count = Repo.aggregate(query, :count, :id) - IO.puts("Database contains #{count} posts tagged with #{tag}") - end) - - user = Repo.all(Pleroma.User) |> List.first() - - Benchee.run( - %{ - "Hashtag fetching" => fn tag -> - Pleroma.Web.MastodonAPI.TimelineController.hashtag_fetching( - %{ - "tag" => tag - }, - user, - false - ) - end - }, - inputs: tags, - 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 |