<commit_before>#
# Author:: <NAME> (<<EMAIL>>)
# Copyright:: Copyright (c) 2013 <NAME>
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

provides "memory"

memory Mash.new

popen4("top -l1 -R -n0") do |pid, stdin, stdout, stderr|
  stdin.close
  stdout.each do |line|
    if line =~ /PhysMem:/
      memory[:total] = "#{$1}#{$2}B" if line =~ /(\d+)([A-Z]{1})\s+used/
      memory[:free] = "#{$1}#{$2}B" if line =~ /(\d+)([A-Z]{1})\s+free/
      memory[:active] = "#{$1}#{$2}B" if line =~ /(\d+)([A-Z]{1})\s+active/
      memory[:inactive] = "#{$1}#{$2}B" if line =~ /(\d+)([A-Z]{1})\s+inactive/
    end
  end
end
<commit_msg>fix in case the unit is not uppercase (kB for kilobytes is an example)<commit_after>#
# Author:: <NAME> (<<EMAIL>>)
# Copyright:: Copyright (c) 2013 <NAME>
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

provides "memory"

memory Mash.new

popen4("top -l1 -R -n0") do |pid, stdin, stdout, stderr|
  stdin.close
  stdout.each do |line|
    if line =~ /PhysMem:/
      memory[:total] = "#{$1}#{$2}B" if line =~ /(\d+)([a-z]{1})\s+used/i
      memory[:free] = "#{$1}#{$2}B" if line =~ /(\d+)([a-z]{1})\s+free/i
      memory[:active] = "#{$1}#{$2}B" if line =~ /(\d+)([a-z]{1})\s+active/i
      memory[:inactive] = "#{$1}#{$2}B" if line =~ /(\d+)([a-z]{1})\s+inactive/i
    end
  end
end

{'fraction_non_alphanumeric': 0.1783172875680201, 'fraction_numerical': 0.020929259104227712, 'mean_word_length': 3.7233201581027666, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4019967', 'n_tokens_mistral': 850, 'n_tokens_neox': 823, 'n_words': 283}