NSIS-ka
A free C++ implementation of NSIS protocols

Changeset 2273

Show
Ignore:
Timestamp:
11/04/06 08:59:01 (7 years ago)
Author:
stud-matfried
Message:

Renamed the benchmark class to benchmark_journal.
We will need the name "benchmark" later.

Location:
natfw-nslp/trunk
Files:
4 modified
2 moved

Legend:

Unmodified
Added
Removed
  • natfw-nslp/trunk/include/benchmark_journal.h

    r2252 r2273  
    55 * $HeadURL$ 
    66 */ 
    7 #ifndef NATFW__BENCHMARK_H 
    8 #define NATFW__BENCHMARK_H 
     7#ifndef NATFW__BENCHMARK_JOURNAL_H 
     8#define NATFW__BENCHMARK_JOURNAL_H 
    99 
    1010#include <iostream> 
     
    2727 * journal. 
    2828 */ 
    29 class benchmark { 
     29class benchmark_journal { 
    3030  public: 
    3131        /** 
     
    4141                PRE_MAPPING             = 3, 
    4242                POST_MAPPING            = 4, 
    43                 PRE_PARSER              = 5, 
    44                 POST_PARSER             = 6, 
    45                 PRE_DISPATCHER          = 7, 
    46                 POST_DISPATCHER         = 8, 
    47                 PRE_SESSION             = 9, 
    48                 POST_SESSION            = 10, 
    49                 HIGHEST_VALID_ID        = 10 
     43                PRE_SERIALIZE           = 5, 
     44                POST_SERIALIZE          = 6, 
     45                PRE_DESERIALIZE         = 7, 
     46                POST_DESERIALIZE        = 8, 
     47                PRE_DISPATCHER          = 9, 
     48                POST_DISPATCHER         = 10, 
     49                PRE_SESSION             = 11, 
     50                POST_SESSION            = 12, 
     51                HIGHEST_VALID_ID        = 12 
    5052        }; 
    5153 
    52         benchmark(int journal_size, const std::string &filename=""); 
    53         ~benchmark(); 
     54        benchmark_journal(int journal_size, const std::string &filename=""); 
     55        ~benchmark_journal(); 
    5456 
    5557        void add(measuring_point_id_t mp_id); 
     
    8486 
    8587 
    86 inline void benchmark::add(measuring_point_id_t mp_id) { 
     88inline void benchmark_journal::add(measuring_point_id_t mp_id) { 
    8789        pthread_mutex_lock(&mutex); 
    8890 
     
    114116 
    115117 
    116 #endif // NATFW__BENCHMARK_H 
     118#endif // NATFW__BENCHMARK_JOURNAL_H 
  • natfw-nslp/trunk/src/Makefile

    r2250 r2273  
    6363        nf_edge_rea_session.o nf_non_edge_rea_session.o natfw_config.o \ 
    6464        policy_rule.o policy_rule_installer.o iptables_policy_rule_installer.o \ 
    65         nat_manager.o gistka_mapper.o natfw_timers.o benchmark.o 
     65        nat_manager.o gistka_mapper.o natfw_timers.o benchmark_journal.o 
    6666 
    6767 
  • natfw-nslp/trunk/src/benchmark_journal.cpp

    r2246 r2273  
    99#include <pthread.h> 
    1010 
    11 #include "benchmark.h" 
     11#include "benchmark_journal.h" 
    1212 
    1313using namespace natfw; 
     
    1717 * Human readable measuring point names, used in write_header(). 
    1818 */ 
    19 const char *benchmark::mp_names[benchmark::HIGHEST_VALID_ID+1] = { 
     19const char * 
     20benchmark_journal::mp_names[benchmark_journal::HIGHEST_VALID_ID+1] = { 
    2021        "INVALID_ID", 
     22        "PRE_PROCESSING", 
     23        "POST_PROCESSING", 
    2124        "PRE_MAPPING", 
    2225        "POST_MAPPING", 
    23         "PRE_PARSER", 
    24         "POST_PARSER", 
     26        "PRE_SERIALIZE", 
     27        "POST_SERIALIZE", 
     28        "PRE_DESERIALIZE", 
     29        "POST_DESERIALIZE", 
    2530        "PRE_DISPATCHER", 
    2631        "POST_DISPATCHER", 
     
    4045 * @param filename the name of the file to write the journal to 
    4146 */ 
    42 benchmark::benchmark(int journal_size, const std::string &filename) 
     47benchmark_journal::benchmark_journal( 
     48                int journal_size, const std::string &filename) 
    4349                : journal_size(journal_size), journal_pos(0), 
    4450                  filename(filename), disable_journal(false) { 
    4551 
    4652        journal = new measuring_point_t[journal_size]; 
    47         memset(journal, 0, sizeof(benchmark::measuring_point_t) * journal_size); 
     53        memset(journal, 0, 
     54                sizeof(benchmark_journal::measuring_point_t) * journal_size); 
    4855 
    4956        /* 
     
    6168 
    6269 
    63 benchmark::~benchmark() { 
     70benchmark_journal::~benchmark_journal() { 
    6471        delete journal; 
    6572        pthread_mutex_destroy(&mutex); 
     
    6774 
    6875 
    69 void benchmark::write_journal(const std::string &filename) { 
     76void benchmark_journal::write_journal(const std::string &filename) { 
    7077        std::ofstream out(filename.c_str()); 
    7178 
     
    9198 * Note that the caller is responsible for closing the stream. 
    9299 */ 
    93 void benchmark::write_journal(std::ostream &out) { 
     100void benchmark_journal::write_journal(std::ostream &out) { 
    94101        pthread_mutex_lock(&mutex); 
    95102 
     
    110117 * Write a header to the journal documenting the measuring points. 
    111118 */ 
    112 void benchmark::write_header(std::ostream &out) { 
     119void benchmark_journal::write_header(std::ostream &out) { 
    113120        time_t t; 
    114121 
  • natfw-nslp/trunk/src/dispatcher.cpp

    r2239 r2273  
    1414#include "dispatcher.h" 
    1515#include "events.h" 
    16 #include "benchmark.h" 
     16#include "benchmark_journal.h" 
    1717 
    1818 
     
    3232 
    3333#ifdef BENCHMARK 
    34   extern benchmark journal; 
     34  extern benchmark_journal journal; 
    3535#endif 
    3636 
     
    140140        if ( s != NULL ) { 
    141141                try { 
    142                         MP(benchmark::PRE_SESSION); 
     142                        MP(benchmark_journal::PRE_SESSION); 
    143143                        s->process(this, evt); 
    144                         MP(benchmark::POST_SESSION); 
     144                        MP(benchmark_journal::POST_SESSION); 
    145145                } 
    146146                catch ( ... ) { 
  • natfw-nslp/trunk/src/gistka_mapper.cpp

    r2263 r2273  
    1414#include "events.h" 
    1515#include "gistka_mapper.h" 
    16 #include "benchmark.h" 
     16#include "benchmark_journal.h" 
    1717 
    1818 
     
    3131 
    3232#ifdef BENCHMARK 
    33   extern benchmark journal; 
     33  extern benchmark_journal journal; 
    3434#endif 
    3535 
     
    4141        using ntlp::nslpdata; 
    4242 
    43         MP(benchmark::PRE_SERIALIZE); 
     43        MP(benchmark_journal::PRE_SERIALIZE); 
    4444 
    4545        /* 
     
    9090                sii_handle, attr, timeout, ip_ttl, ntlp_hop_count); 
    9191 
    92         MP(benchmark::POST_SERIALIZE); 
     92        MP(benchmark_journal::POST_SERIALIZE); 
    9393 
    9494        return apimsg; 
     
    106106        assert( msg != NULL ); 
    107107 
    108         MP(benchmark::PRE_MAPPING); 
     108        MP(benchmark_journal::PRE_MAPPING); 
    109109 
    110110        if ( dynamic_cast<const APIMsg *>(msg) != NULL ) 
     
    126126                LogWarn("map_to_event(): mapping not possible"); 
    127127 
    128         MP(benchmark::POST_MAPPING); 
     128        MP(benchmark_journal::POST_MAPPING); 
    129129 
    130130        return ret; 
     
    207207         * Parse the NSLP payload (the NTLP's body). 
    208208         */ 
    209         MP(benchmark::PRE_DESERIALIZE); 
     209        MP(benchmark_journal::PRE_DESERIALIZE); 
    210210        NetMsg payload(data->get_buffer(), data->get_size()); // copies the data 
    211211        NATFW_IEManager *mgr = NATFW_IEManager::instance(); 
     
    243243        msg_event *evt = new msg_event(sid, ret, final_hop); 
    244244 
    245         MP(benchmark::POST_DESERIALIZE); 
     245        MP(benchmark_journal::POST_DESERIALIZE); 
    246246 
    247247        return evt; 
  • natfw-nslp/trunk/src/natfw_daemon.cpp

    r2268 r2273  
    1111#include "dispatcher.h" 
    1212#include "natfw_daemon.h" 
    13 #include "benchmark.h" 
     13#include "benchmark_journal.h" 
    1414 
    1515 
     
    2727 
    2828#ifdef BENCHMARK 
    29   benchmark journal(10000, "benchmark_journal.txt"); 
     29  benchmark_journal journal(1000, "benchmark_journal.txt"); 
    3030#endif 
    3131 
     
    196196                        << " processing received message #" << msg->get_id()); 
    197197 
    198                 MP(benchmark::PRE_PROCESSING); 
     198                MP(benchmark_journal::PRE_PROCESSING); 
    199199 
    200200                // Analyze message and create an event from it. 
     
    203203                // Then feed the event to the dispatcher. 
    204204                if ( evt != NULL ) { 
    205                         MP(benchmark::PRE_DISPATCHER); 
     205                        MP(benchmark_journal::PRE_DISPATCHER); 
    206206                        disp.process(evt); 
    207                         MP(benchmark::POST_DISPATCHER); 
     207                        MP(benchmark_journal::POST_DISPATCHER); 
    208208                        delete evt; 
    209209                } 
     
    211211                delete msg; 
    212212 
    213                 MP(benchmark::POST_PROCESSING); 
     213                MP(benchmark_journal::POST_PROCESSING); 
    214214        } 
    215215}