<commit_before>/* ****************************************************************************
*
* FILE                     main_samsonWorker.cpp
*
* AUTHOR                   <NAME>
*
* CREATION DATE            Dec 14 2010
*
*/
#include "parseArgs/parseArgs.h"
#include "logMsg/logMsg.h"
#include "logMsg/traceLevels.h"

#include <signal.h>


#include "au/LockDebugger.h"            // au::LockDebugger
#include "au/Cronometer.h"
#include "au/time.h"
#include "au/string.h"


#include "engine/MemoryManager.h"
#include "engine/Engine.h"
#include "engine/DiskManager.h"
#include "engine/ProcessManager.h"
#include "engine/Notification.h"

#include "samson/common/samsonVersion.h"
#include "samson/common/samsonVars.h"
#include "samson/common/platformProcesses.h"
#include "samson/common/SamsonSetup.h"
#include "samson/network/Network2.h"
#include "samson/network/Endpoint2.h"
#include "samson/network/EndpointManager.h"
#include "samson/worker/SamsonWorker.h"
#include "samson/isolated/SharedMemoryManager.h"
#include "samson/stream/BlockManager.h"
#include "samson/module/ModulesManager.h"



/* ****************************************************************************
*
* Option variables
*/
SAMSON_ARG_VARS;


/* ****************************************************************************
*
* parse arguments
*/
PaArgument paArgs[] =
{
	SAMSON_ARGS,
	PA_END_OF_ARGS
};

/* ****************************************************************************
*
* global variables
*/
int                   logFd             = -1;


/* ****************************************************************************
*
* man texts -
*/
static const char* manSynopsis         = " [OPTION]";
static const char* manShortDescription = "samsonDiskTest is a simple tool to analyse disk performance in a SAMSON deployment.\n\n";
static const char* manDescription      =
    "\n"
    "samsonDiskTest is a simple tool to analyse disk performance in a SAMSON deployment."
    "\n";

static const char* manExitStatus    = "0      if OK\n 1-255  error\n";
static const char* manAuthor        = "Written by <NAME>, <NAME> and <NAME>.";
static const char* manReportingBugs = "bugs to samson-dev@tid.es\n";
static const char* manCopyright     = "Copyright (C) 2011 Telefonica Investigacion y Desarrollo";
static const char* manVersion       = SAMSON_VERSION;


/* ****************************************************************************
 *
 * Test - 
 */

class Test : public engine::Object
{
    
    // Setup of the test
    int num_threads;
    
    // Cronometer
    au::Cronometer cronometer;
    au::Cronometer cronometer_show_status;
    
    // Write operations
    int files_num;
    int files_size;
    
    // Progress 
    int files_num_write;
    int files_num_read;
    int files_num_remove;
    
    // Flag to indicate finish of test
    bool finish;
    size_t accumulated_size;
    
    // Temporal buffer for reads...
    char * read_data;

    // Final time when finishing test
    size_t final_time;
    
    public:
    
    Test( int _num_threads )
    {
        
        // Setup for this test
        num_threads = _num_threads;
        
        // Common setup
        files_num = 100;
        files_size = 64000000;
        
        files_num_write=0;
        files_num_read=0;
        files_num_remove=0;
        
        accumulated_size = 0;

        read_data = (char*) malloc( files_size );
        finish = false;
    }
    
    ~Test()
    {
        free( read_data );
    }
    
    
    std::string str_results()
    {
        return au::str("Test with %02d threads .............. Time %s / Rate %s " , 
                       num_threads,
                       au::str_time( final_time).c_str() ,
                       au::str_rate( accumulated_size, final_time ).c_str()
                       );
    }
    <commit_msg>SAMSON-276 size and files parameters for  samsonDiskTest<commit_after>/* ****************************************************************************
*
* FILE                     main_samsonWorker.cpp
*
* AUTHOR                   <NAME>
*
* CREATION DATE            Dec 14 2010
*
*/
#include "parseArgs/parseArgs.h"
#include "logMsg/logMsg.h"
#include "logMsg/traceLevels.h"

#include <signal.h>


#include "au/LockDebugger.h"            // au::LockDebugger
#include "au/Cronometer.h"
#include "au/time.h"
#include "au/string.h"


#include "engine/MemoryManager.h"
#include "engine/Engine.h"
#include "engine/DiskManager.h"
#include "engine/ProcessManager.h"
#include "engine/Notification.h"

#include "samson/common/samsonVersion.h"
#include "samson/common/samsonVars.h"
#include "samson/common/platformProcesses.h"
#include "samson/common/SamsonSetup.h"
#include "samson/network/Network2.h"
#include "samson/network/Endpoint2.h"
#include "samson/network/EndpointManager.h"
#include "samson/worker/SamsonWorker.h"
#include "samson/isolated/SharedMemoryManager.h"
#include "samson/stream/BlockManager.h"
#include "samson/module/ModulesManager.h"



/* ****************************************************************************
*
* Option variables
*/
SAMSON_ARG_VARS;

int param_num_files;
int param_file_size;

/* ****************************************************************************
*
* parse arguments
*/
PaArgument paArgs[] =
{
	SAMSON_ARGS,
    { "-size",      &param_file_size,  "",  PaInt,     PaOpt,     64,   1, 1024,  "Size in megabytes of each file" },
    { "-files",     &param_num_files,  "",  PaInt,     PaOpt,     100,  1, 1024,  "Number of files" },
	PA_END_OF_ARGS
};

/* ****************************************************************************
*
* global variables
*/
int                   logFd             = -1;


/* ****************************************************************************
*
* man texts -
*/
static const char* manSynopsis         = " [OPTION]";
static const char* manShortDescription = "samsonDiskTest is a simple tool to analyse disk performance in a SAMSON deployment.\n\n";
static const char* manDescription      =
    "\n"
    "samsonDiskTest is a simple tool to analyse disk performance in a SAMSON deployment."
    "\n";

static const char* manExitStatus    = "0      if OK\n 1-255  error\n";
static const char* manAuthor        = "Written by <NAME>, <NAME> and <NAME>.";
static const char* manReportingBugs = "bugs to sam<EMAIL>.es\n";
static const char* manCopyright     = "Copyright (C) 2011 Telefonica Investigacion y Desarrollo";
static const char* manVersion       = SAMSON_VERSION;


/* ****************************************************************************
 *
 * Test - 
 */

class Test : public engine::Object
{
    
    // Setup of the test
    int num_threads;
    
    // Cronometer
    au::Cronometer cronometer;
    au::Cronometer cronometer_show_status;
    
    // Write operations
    int files_num;
    int files_size;
    
    // Progress 
    int files_num_write;
    int files_num_read;
    int files_num_remove;
    
    // Flag to indicate finish of test
    bool finish;
    size_t accumulated_size;
    
    // Temporal buffer for reads...
    char * read_data;

    // Final time when finishing test
    size_t final_time;
    
    public:
    
    Test( int _num_threads )
    {
        
        // Setup for this test
        num_threads = _num_threads;
        
        // Common setup
        
        files_num = param_num_files;
        files_size = param_file_size * 1024 * 1024;
        
        files_num_write=0;
        files_num_read=0;
        files_num_remove=0;
        
        accumulated_size = 0;

        read_data = (char*) malloc( files_size );
        finish = false;
    }
    
    ~Test()
    {
        free( read_data );
    }
    
    
    std::string str_results()
    {
        return au::str("Test with %02d threads .............. Time %s / Accumulated size %s / Rate %s " , 
                       num_threads,
                       au::str_time( final_time ).c_str() ,
                       au::str( accumulated_size ).c_str() ,
                       au::str_time( final_time).c_str()
                       );
    }
    
{'fraction_non_alphanumeric': 0.21505376344086022, 'fraction_numerical': 0.010505499938202942, 'mean_word_length': 2.648331830477908, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, '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': '516944', 'n_tokens_mistral': 2517, 'n_tokens_neox': 2370, 'n_words': 556}