Skip to content

Commit

Permalink
ifndef WITH_INTERNAL_METRICS then lets not
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-c committed Mar 10, 2014
1 parent 7e8a2c1 commit 85ca06a
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 31 deletions.
6 changes: 6 additions & 0 deletions .ycm_extra_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@
'/usr/include',
'-isystem',
'/usr/local/include',
'-system',
'/usr/include/c++/4.8',
'-I',
'/usr/include/python2.7',
'-I',
'lib'
]


Expand Down
4 changes: 3 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
scalar field (UNINIT_CTOR)
* lib/node.cc: fix for Coverity CID 1173035: Uninitialized scalar field
(UNINIT_CTOR)

* lib/hashbits.hh: fix for Coverity CID 1153101: Resource leak in object
(CTOR_DTOR_LEAK)
* lib/{perf_metrics.{cc,hh},hashtable.{cc,hh}
,read_parsers.{cc,hh},trace_logger.{cc,hh}}: ifndef WITH_INTERNAL_METRICS
then lets not + astyle -A10

2014-02-27 Michael R. Crusoe <mcrusoe@msu.edu>

Expand Down
6 changes: 4 additions & 2 deletions lib/hashtable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ using namespace std;
using namespace khmer;
using namespace khmer:: read_parsers;


#ifdef WITH_INTERNAL_METRICS
HashTablePerformanceMetrics::
HashTablePerformanceMetrics( )
: IPerformanceMetrics( ),
Expand Down Expand Up @@ -62,7 +62,7 @@ accumulate_timer_deltas( uint32_t metrics_key )
}

}

#endif

Hashtable:: Hasher::
Hasher(
Expand All @@ -72,7 +72,9 @@ Hasher(
)
: pool_id( pool_id ),
thread_id( thread_id ),
#ifdef WITH_INTERNAL_METRICS
pmetrics( HashTablePerformanceMetrics( ) ),
#endif
trace_logger(
TraceLogger(
trace_level, "hashtable-%lu-%lu.log",
Expand Down
6 changes: 4 additions & 2 deletions lib/hashtable.hh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#define CALLBACK_PERIOD 100000

namespace khmer {

#ifdef WITH_INTERNAL_METRICS
struct HashTablePerformanceMetrics : public IPerformanceMetrics
{

Expand All @@ -60,7 +60,7 @@ namespace khmer {
virtual void accumulate_timer_deltas( uint32_t metrics_key );

};

#endif
//
// Sequence iterator class, test. Not really a C++ iterator yet.
//
Expand Down Expand Up @@ -152,7 +152,9 @@ namespace khmer {

uint32_t pool_id;
uint32_t thread_id;
#ifdef WITH_INTERNAL_METRICS
HashTablePerformanceMetrics pmetrics;
#endif
TraceLogger trace_logger;

Hasher(
Expand Down
4 changes: 2 additions & 2 deletions lib/perf_metrics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace khmer
{


#ifdef WITH_INTERNAL_METRICS
IPerformanceMetrics::
IPerformanceMetrics( )
{ }
Expand All @@ -28,7 +28,7 @@ _timespec_diff_in_nsecs( timespec const &start, timespec const &stop )
((stop.tv_sec * 1000000000U) + (uint64_t)stop.tv_nsec)
- ((start.tv_sec * 1000000000U) + (uint64_t)start.tv_nsec);
}

#endif
} // namespace khmer

// vim: set ft=cpp sts=4 sw=4 tw=79:
11 changes: 6 additions & 5 deletions lib/perf_metrics.hh
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@
namespace khmer
{


#ifdef WITH_INTERNAL_METRICS
struct InvalidPerformanceMetricsKey : public std:: exception
{ };


struct IPerformanceMetrics
{

IPerformanceMetrics( );
IPerformanceMetrics( );
virtual ~IPerformanceMetrics( );

inline void start_timers( )
{
#if defined (__linux__)
clock_gettime( CLOCK_REALTIME, &_temp_clock_start );
clock_gettime( CLOCK_THREAD_CPUTIME_ID, &_temp_cpu_start );
// TODO: Create proper stopwatches for MacOS X and Windows.
// TODO: Create proper stopwatches for MacOS X.
#else
memset( &_temp_clock_start, 0, sizeof( timespec ) );
memset( &_temp_cpu_start, 0, sizeof( timespec ) );
Expand All @@ -46,7 +46,7 @@ struct IPerformanceMetrics
#if defined (__linux__)
clock_gettime( CLOCK_THREAD_CPUTIME_ID, &_temp_cpu_stop );
clock_gettime( CLOCK_REALTIME, &_temp_clock_stop );
// TODO: Create proper stopwatches for MacOS X and Windows.
// TODO: Create proper stopwatches for MacOS X.
#else
memset( &_temp_cpu_stop, 0, sizeof( timespec ) );
memset( &_temp_clock_stop, 0, sizeof( timespec ) );
Expand All @@ -69,8 +69,9 @@ protected:

};

} // namespace khmer
#endif // WITH_INTERNAL_METRICS

} // namespace khmer
#endif // PERF_METRICS_HH

// vim: set ft=cpp sts=4 sw=4 tw=79:
21 changes: 14 additions & 7 deletions lib/read_parsers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ InvalidFASTQFileFormat( char const * reason, char const * evidence )
: InvalidReadFileFormat( "InvalidFASTQFileFormat", reason, evidence )
{ }


#ifdef WITH_INTERNAL_METRICS
StreamReaderPerformanceMetrics::
StreamReaderPerformanceMetrics( )
: IPerformanceMetrics( ),
Expand Down Expand Up @@ -95,11 +95,14 @@ accumulate_timer_deltas( uint32_t metrics_key )
}

}

#endif

IStreamReader::
IStreamReader( )
: pmetrics( StreamReaderPerformanceMetrics( ) ),
:
#ifdef WITH_INTERNAL_METRICS
pmetrics( StreamReaderPerformanceMetrics( ) ),
#endif
_alignment( 0 ),
_max_aligned( SSIZE_MAX ),
_at_eos( false )
Expand Down Expand Up @@ -374,7 +377,7 @@ read_into_cache( uint8_t * const cache, uint64_t const cache_size )
return nbread_total;
}


#ifdef WITH_INTERNAL_METRICS
CacheSegmentPerformanceMetrics::
CacheSegmentPerformanceMetrics( )
: IPerformanceMetrics( ),
Expand Down Expand Up @@ -481,7 +484,7 @@ accumulate_metrics( CacheSegmentPerformanceMetrics &source )
source._accumulated_count;

}

#endif

CacheManager::
CacheManager(
Expand Down Expand Up @@ -548,7 +551,9 @@ CacheSegment(
cursor_in_ca_buffer( false ),
fill_id( 0 ),
found_EOS( false ),
#ifdef WITH_INTERNAL_METRICS
pmetrics( CacheSegmentPerformanceMetrics( ) ),
#endif
trace_logger(
TraceLogger(
trace_level, "cmgr-%lu.log", (unsigned long int)thread_id
Expand Down Expand Up @@ -1176,7 +1181,7 @@ _get_segment_ref_count_ATOMIC( )
return __sync_and_and_fetch( &_segment_ref_count, (uint32_t)0xffffffff );
}


#ifdef WITH_INTERNAL_METRICS
ParserPerformanceMetrics::
ParserPerformanceMetrics( )
: numlines_copied( 0 ),
Expand All @@ -1194,7 +1199,7 @@ void
ParserPerformanceMetrics::
accumulate_timer_deltas( uint32_t metrics_key )
{ }

#endif

IParser * const
IParser::
Expand Down Expand Up @@ -1374,7 +1379,9 @@ ParserState( uint32_t const thread_id, uint8_t const trace_level )
need_new_line( true ),
buffer_pos( 0 ),
buffer_rem( 0 ),
#ifdef WITH_INTERNAL_METRICS
pmetrics( ParserPerformanceMetrics( ) ),
#endif
trace_logger(
TraceLogger(
trace_level, "parser-%lu.log", (unsigned long int)thread_id
Expand Down
20 changes: 12 additions & 8 deletions lib/read_parsers.hh
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ struct UnknownPairReadingMode : public std:: exception
struct InvalidReadPair : public std:: exception
{ };


#ifdef WITH_INTERNAL_METRICS
struct StreamReaderPerformanceMetrics : public IPerformanceMetrics
{

Expand All @@ -117,13 +117,13 @@ struct StreamReaderPerformanceMetrics : public IPerformanceMetrics
virtual void accumulate_timer_deltas( uint32_t metrics_key );

};

#endif

struct IStreamReader
{

#ifdef WITH_INTERNAL_METRICS
StreamReaderPerformanceMetrics pmetrics;
#endif
IStreamReader( );
virtual ~IStreamReader( );

Expand Down Expand Up @@ -198,7 +198,7 @@ private:

};


#ifdef WITH_INTERNAL_METRICS
struct CacheSegmentPerformanceMetrics : public IPerformanceMetrics
{

Expand Down Expand Up @@ -240,7 +240,7 @@ protected:
uint32_t _accumulated_count;

};

#endif

struct CacheManager
{
Expand Down Expand Up @@ -285,7 +285,9 @@ private:
std:: string ca_buffer;
uint64_t fill_id;
bool found_EOS;
#ifdef WITH_INTERNAL_METRICS
CacheSegmentPerformanceMetrics pmetrics;
#endif
TraceLogger trace_logger;

CacheSegment(
Expand Down Expand Up @@ -360,7 +362,7 @@ struct Read

typedef std:: pair< Read, Read > ReadPair;


#ifdef WITH_INTERNAL_METRICS
struct ParserPerformanceMetrics: public IPerformanceMetrics
{

Expand All @@ -374,6 +376,7 @@ struct ParserPerformanceMetrics: public IPerformanceMetrics
virtual void accumulate_timer_deltas( uint32_t metrics_key );

};
#endif


struct IParser
Expand Down Expand Up @@ -446,8 +449,9 @@ protected:
uint8_t buffer[ BUFFER_SIZE + 1 ];
uint64_t buffer_pos;
uint64_t buffer_rem;

#ifdef WITH_INTERNAL_METRICS
ParserPerformanceMetrics pmetrics;
#endif
TraceLogger trace_logger;

ParserState( uint32_t const thread_id, uint8_t const trace_level );
Expand Down
2 changes: 1 addition & 1 deletion lib/trace_logger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ TraceLogger( uint8_t const level, FILE * stream_handle )

TraceLogger::
TraceLogger( uint8_t const level, char const * const file_name_format, ... )
: _level( level ), _shared_stream( false )
#ifdef WITH_INTERNAL_TRACING
: _level( level ), _shared_stream( false )
{
char tfile_name[ FILENAME_MAX + 1 ];
va_list varargs;
Expand Down
5 changes: 2 additions & 3 deletions lib/trace_logger.hh
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,9 @@ struct TraceLogger {
#endif // !WITH_INTERNAL_TRACING

private:

uint8_t _level;
bool _shared_stream;
#ifdef WITH_INTERNAL_TRACING
bool _shared_stream;
uint8_t _level;
FILE * _stream_handle;
#endif
};
Expand Down

0 comments on commit 85ca06a

Please sign in to comment.