• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nshkrdotcom / ElixirScope / 997dd201c48cfc5a93ab9d8799c4f839ab1728ae

29 May 2025 07:59PM UTC coverage: 58.374% (-0.05%) from 58.426%
997dd201c48cfc5a93ab9d8799c4f839ab1728ae

push

github

NSHkr
refactor performance_optimizer

0 of 159 new or added lines in 6 files covered. (0.0%)

14 existing lines in 1 file now uncovered.

6082 of 10419 relevant lines covered (58.37%)

3184.09 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/lib/elixir_scope/ast_repository/performance_optimizer/optimization_scheduler.ex
1
# ==============================================================================
2
# Optimization Scheduler Component
3
# ==============================================================================
4

5
defmodule ElixirScope.ASTRepository.PerformanceOptimizer.OptimizationScheduler do
6
  @moduledoc """
7
  Schedules and manages periodic optimization tasks.
8
  """
9

10
  use GenServer
11
  require Logger
12

13
  alias ElixirScope.ASTRepository.MemoryManager
14

15
  @optimization_interval 600_000   # 10 minutes
16

17
  def start_link(opts \\ []) do
NEW
18
    GenServer.start_link(__MODULE__, opts, name: __MODULE__)
×
19
  end
20

21
  def init(_opts) do
NEW
22
    schedule_optimization_cycle()
×
23
    {:ok, %{}}
24
  end
25

26
  @doc """
27
  Optimizes ETS table structures and indexes.
28
  """
29
  @spec optimize_ets_tables() :: :ok
30
  def optimize_ets_tables() do
NEW
31
    GenServer.cast(__MODULE__, :optimize_ets_tables)
×
32
  end
33

34
  def handle_cast(:optimize_ets_tables, state) do
NEW
35
    perform_ets_optimization()
×
36
    {:noreply, state}
37
  end
38

39
  def handle_info(:optimization_cycle, state) do
NEW
40
    perform_optimization_cycle()
×
NEW
41
    schedule_optimization_cycle()
×
42
    {:noreply, state}
43
  end
44

45
  # Private implementation
46
  defp perform_ets_optimization() do
NEW
47
    Logger.debug("Performing ETS optimization")
×
48
    # Placeholder for ETS optimization logic
49
    :ok
50
  end
51

52
  defp perform_optimization_cycle() do
NEW
53
    Logger.debug("Performing optimization cycle")
×
54

NEW
55
    {:ok, memory_stats} = MemoryManager.monitor_memory_usage()
×
56

NEW
57
    if memory_stats.memory_usage_percent > 70 do
×
NEW
58
      MemoryManager.cleanup_unused_data(max_age: 3600)
×
59
    end
60

NEW
61
    if memory_stats.memory_usage_percent > 60 do
×
NEW
62
      MemoryManager.compress_old_analysis(access_threshold: 5, age_threshold: 1800)
×
63
    end
64
  end
65

66
  defp schedule_optimization_cycle() do
NEW
67
    Process.send_after(self(), :optimization_cycle, @optimization_interval)
×
68
  end
69
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc