<commit_before>//******************************************************
//** Author: <NAME>
//** 
//** The MomoryInfo class provides a interface to access memory informations
//** for the current process or system-wide across diffrent platforms.
//** It provides interfaces to get the:
//**  - current physically used memory by the process
//**  - current virtual    used memory by the process
//**  - maximal physically used memory by the process so far
//**  - maximal virtual    used memory by the process so far
//**
//**  - used physical memory of the system
//**  - free physical memory of the system
//**  - total physical memory of the system 
//**
//******************************************************

#pragma once
#ifndef SYS_MEMORYINFO_HXX
#define SYS_MEMORYINFO_HXX

#include <iostream>
#include <stdexcept>
#include "stdlib.h"
#include "stdio.h"
#include "string.h"

# if  ( defined(__APPLE__))
#   define SYS_MEMORYINFO_MAC
#include <mach/vm_statistics.h>
#include <mach/mach_types.h> 
#include <mach/mach_init.h>
#include <mach/mach_host.h>
#include <mach/mach.h>
# elif (defined(_WIN32) || defined(WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(_WIN64))
#   define SYS_MEMORYINFO_WINDOWS 
#   include <windows.h>
#   include <psapi.h>
#   undef min
#   undef max
# else
#   define SYS_MEMORYINFO_LINUX
#   include <unistd.h>
#   include "sys/types.h"
#   include "sys/sysinfo.h"
# endif
namespace sys {

   class MemoryInfo{
   public:
      inline static double usedVirtualMem();
      inline static double usedPhysicalMem();
      inline static double usedVirtualMemMax();
      inline static double usedPhysicalMemMax();

      inline static double usedSystemMem();
      inline static double freeSystemMem();
      inline static double systemMem();
   private:
      
      inline static int parseLine(char* line){
         int i = strlen(line);
         while (*line < '0' || *line > '9') line++;
         line[i-3] = '\0';
         i = atoi(line);
         return i;
      }
   };

//**************************************
//**
//**   Implementation for Linux
//**
//*************************************<commit_msg>add simple option to deactivate memory logging for non supported platforms or other problems<commit_after>//******************************************************
//** Author: <NAME>
//** 
//** The MomoryInfo class provides a interface to access memory informations
//** for the current process or system-wide across diffrent platforms.
//** It provides interfaces to get the:
//**  - current physically used memory by the process
//**  - current virtual    used memory by the process
//**  - maximal physically used memory by the process so far
//**  - maximal virtual    used memory by the process so far
//**
//**  - used physical memory of the system
//**  - free physical memory of the system
//**  - total physical memory of the system 
//**
//******************************************************

#pragma once
#ifndef SYS_MEMORYINFO_HXX
#define SYS_MEMORYINFO_HXX

#include <iostream>
#include <stdexcept>
#include "stdlib.h"
#include "stdio.h"
#include "string.h"

// uncomment this line if U have problems with memorylogging -> this will disable it.
#define SYS_MEMORYINFO_ON

#if ( defined(__APPLE__) &&  defined(SYS_MEMORYINFO_ON) )
#   define SYS_MEMORYINFO_MAC
#   include <mach/vm_statistics.h>
#   include <mach/mach_types.h> 
#   include <mach/mach_init.h>
#   include <mach/mach_host.h>
#   include <mach/mach.h>
#elif (defined(SYS_MEMORYINFO_ON) && (defined(_WIN32) || defined(WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(_WIN64)) )
#   define SYS_MEMORYINFO_WINDOWS 
#   include <windows.h>
#   include <psapi.h>
#   undef min
#   undef max
#elif (defined(SYS_MEMORYINFO_ON))
#   define SYS_MEMORYINFO_LINUX
#   include <unistd.h>
#   include "sys/types.h"
#   include "sys/sysinfo.h"
#else
#endif
namespace sys {

   class MemoryInfo{
   public:
      inline static double usedVirtualMem();
      inline static double usedPhysicalMem();
      inline static double usedVirtualMemMax();
      inline static double usedPhysicalMemMax();

      inline static double usedSystemMem();
      inline static double freeSystemMem();
      inline static double systemMem();
   private:
      
      inline static int parseLine(char* line){
         int i = strlen(line);
         while (*line < '0' || *line > '9') line++;
         line[i-3] = '\0';
         i = atoi(line);
         return i;
      }
   };

//**************************************
//**
//**   Implementation for Linux
//**
//*************************************
{'fraction_non_alphanumeric': 0.19493725659887495, 'fraction_numerical': 0.005192557334487235, 'mean_word_length': 3.536800785083415, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 28, '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': '2998482', 'n_tokens_mistral': 1400, 'n_tokens_neox': 1362, 'n_words': 414}