<commit_before>#include <htl_stdinc.hpp>

// system
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#include <sys/time.h>
#include <inttypes.h>

// socket
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

// dns
#include <netdb.h>

#include <string>
using namespace std;

#include <htl_core_error.hpp>
#include <htl_core_log.hpp>

#include <htl_os_st.hpp>

StStatistic::StStatistic(){
    starttime = StUtility::GetCurrentTime();
    threads = alive = 0;
    nread = nwrite = 0;
    tasks = err_tasks = sub_tasks = err_sub_tasks = 0;
}

StStatistic::~StStatistic(){
}

void StStatistic::OnRead(int /*tid*/, ssize_t nread){
    this->nread += nread;
}

void StStatistic::OnWrite(int /*tid*/, ssize_t nwrite){
    this->nwrite += nwrite;
}

void StStatistic::OnThreadRun(int /*tid*/){
    threads++;
}

void StStatistic::OnThreadQuit(int /*tid*/){
    threads--;
}

void StStatistic::OnTaskStart(int /*tid*/, std::string /*task_url*/){
    alive++;
    tasks++;
}

void StStatistic::OnTaskError(int /*tid*/){
    alive--;
    err_tasks++;
}

void StStatistic::OnTaskEnd(int /*tid*/){
    alive--;
}

void StStatistic::OnSubTaskStart(int /*tid*/, std::string /*sub_task_url*/){
    sub_tasks++;
}

void StStatistic::OnSubTaskError(int /*tid*/){
    err_sub_tasks++;
}

void StStatistic::OnSubTaskEnd(int /*tid*/){
}

void StStatistic::DoReport(double sleep_ms){
    for(;;){
        int64_t duration = StUtility::GetCurrentTime() - starttime;
        double read_mbps = 0, write_mbps = 0;
        
        if(duration > 0){
            read_mbps = nread * 8.0 / duration / 1000 / 1000;
            write_mbps = nwrite * 8.0 / duration / 1000 / 1000;
        }
        <commit_msg>fix bug of statistic of Mbps.<commit_after>#include <htl_stdinc.hpp>

// system
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#include <sys/time.h>
#include <inttypes.h>

// socket
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

// dns
#include <netdb.h>

#include <string>
using namespace std;

#include <htl_core_error.hpp>
#include <htl_core_log.hpp>

#include <htl_os_st.hpp>

StStatistic::StStatistic(){
    starttime = StUtility::GetCurrentTime();
    threads = alive = 0;
    nread = nwrite = 0;
    tasks = err_tasks = sub_tasks = err_sub_tasks = 0;
}

StStatistic::~StStatistic(){
}

void StStatistic::OnRead(int /*tid*/, ssize_t nread){
    this->nread += nread;
}

void StStatistic::OnWrite(int /*tid*/, ssize_t nwrite){
    this->nwrite += nwrite;
}

void StStatistic::OnThreadRun(int /*tid*/){
    threads++;
}

void StStatistic::OnThreadQuit(int /*tid*/){
    threads--;
}

void StStatistic::OnTaskStart(int /*tid*/, std::string /*task_url*/){
    alive++;
    tasks++;
}

void StStatistic::OnTaskError(int /*tid*/){
    alive--;
    err_tasks++;
}

void StStatistic::OnTaskEnd(int /*tid*/){
    alive--;
}

void StStatistic::OnSubTaskStart(int /*tid*/, std::string /*sub_task_url*/){
    sub_tasks++;
}

void StStatistic::OnSubTaskError(int /*tid*/){
    err_sub_tasks++;
}

void StStatistic::OnSubTaskEnd(int /*tid*/){
}

void StStatistic::DoReport(double sleep_ms){
    for(;;){
        int64_t duration = StUtility::GetCurrentTime() - starttime;
        double read_mbps = 0, write_mbps = 0;
        
        if(duration > 0){
            read_mbps = nread * 8.0 / duration / 1000;
            write_mbps = nwrite * 8.0 / duration / 1000;
        }
        
{'fraction_non_alphanumeric': 0.17036820572764466, 'fraction_numerical': 0.014026884862653419, 'mean_word_length': 3.394094993581515, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 37, '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': '6498907', 'n_tokens_mistral': 1323, 'n_tokens_neox': 1288, 'n_words': 257}