<commit_before># -*- encoding: utf-8 -*-
module Bluepill
  module ProcessConditions
    class MemUsage < ProcessCondition
      MB = 1024 ** 2
      FORMAT_STR = "%d%s"
      MB_LABEL = "MB"
      KB_LABEL = "KB"

      def initialize(options = {})
        @below = options[:below]
      end

      def run(pid, include_children)
        # rss is on the 5th col
        System.memory_usage(pid, include_children).to_f
      end

      def check(value)
        value.kilobytes < @below
      end

      def format_value(value)
        if value.kilobytes >= MB
          FORMAT_STR % [(value / 1024).round, MB_LABEL]
        else
          FORMAT_STR % [value, KB_LABEL]
        end
      end
    end
  end
end<commit_msg>Will true on unused process. closes #16<commit_after># -*- encoding: utf-8 -*-
module Bluepill
  module ProcessConditions
    class MemUsage < ProcessCondition
      MB = 1024 ** 2
      FORMAT_STR = "%d%s"
      MB_LABEL = "MB"
      KB_LABEL = "KB"

      def initialize(options = {})
        @below = options[:below]
      end

      def run(pid, include_children)
        # rss is on the 5th col
        System.memory_usage(pid, include_children).to_f
      end

      def check(value)
        value.kilobytes < @below rescue true
      end

      def format_value(value)
        if value.kilobytes >= MB
          FORMAT_STR % [(value / 1024).round, MB_LABEL]
        else
          FORMAT_STR % [value, KB_LABEL]
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.09336941813261164, 'fraction_numerical': 0.016238159675236806, 'mean_word_length': 1.9, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4659652', 'n_tokens_mistral': 499, 'n_tokens_neox': 458, 'n_words': 125}