11/* **
2- * Filename: Streamer.cpp
3- *
42 * Description: Stream table data.
53 *
6- * Version: 0.0.1
7- * Created: 2016-04-26
8-
9- * Revision: none
10- *
114 * Author: Dilawar Singh <[email protected] > 125 * Organization: NCBS Bangalore
13- *
14- * License: GNU GPL2
156 */
167
178#include < algorithm>
@@ -45,12 +36,18 @@ const Cinfo* Streamer::initCinfo()
4536 , &Streamer::getFormat
4637 );
4738
48- static ReadOnlyValueFinfo< Streamer, size_t > numTables (
39+ static ReadOnlyValueFinfo<Streamer, size_t > numTables (
4940 " numTables"
5041 , " Number of Tables handled by Streamer "
5142 , &Streamer::getNumTables
5243 );
5344
45+ static ReadOnlyValueFinfo<Streamer, size_t > numWriteEvents (
46+ " numWriteEvents"
47+ , " Number of time streamer was called to write. (For debugging/performance reason only)"
48+ , &Streamer::getNumWriteEvents
49+ );
50+
5451 /* -----------------------------------------------------------------------------
5552 *
5653 *-----------------------------------------------------------------------------*/
@@ -96,7 +93,7 @@ const Cinfo* Streamer::initCinfo()
9693 *-----------------------------------------------------------------------------*/
9794 static Finfo* procShared[] =
9895 {
99- &process , &reinit , &addTable, &addTables, &removeTable, &removeTables
96+ &process, &reinit, &addTable, &addTables, &removeTable, &removeTables
10097 };
10198
10299 static SharedFinfo proc (
@@ -107,7 +104,7 @@ const Cinfo* Streamer::initCinfo()
107104
108105 static Finfo * tableStreamFinfos[] =
109106 {
110- &outfile, &format, &proc, &numTables
107+ &outfile, &format, &proc, &numTables, &numWriteEvents
111108 };
112109
113110 static string doc[] =
@@ -140,8 +137,9 @@ Streamer::Streamer()
140137{
141138 // Not all compilers allow initialization during the declaration of class
142139 // methods.
143- format_ = " npy" ;
144- columns_.push_back ( " time" ); /* First column is time. */
140+ format_ = " csv" ;
141+ numWriteEvents_ = 0 ;
142+ columns_.push_back (" time" ); /* First column is time. */
145143 tables_.resize (0 );
146144 tableIds_.resize (0 );
147145 tableTick_.resize (0 );
@@ -238,7 +236,7 @@ void Streamer::reinit(const Eref& e, ProcPtr p)
238236 // write now.
239237 currTime_ = 0.0 ;
240238 zipWithTime ( );
241- StreamerBase::writeToOutFile ( outfilePath_, format_, " w" , data_, columns_);
239+ StreamerBase::writeToOutFile (outfilePath_, format_, " w" , data_, columns_);
242240 data_.clear ( );
243241}
244242
@@ -261,15 +259,11 @@ void Streamer::cleanUp( )
261259 */
262260void Streamer::process (const Eref& e, ProcPtr p)
263261{
264- // LOG( moose::debug, "Writing to table " );
262+ // LOG( moose::debug, "Writing Streamer data to file. " );
265263 zipWithTime ( );
266-
267- // Write only if there are more than 100 entry in first table.
268- if ( tables_[0 ]->getVecSize () > 100 )
269- {
270- StreamerBase::writeToOutFile ( outfilePath_, format_, " a" , data_, columns_ );
271- data_.clear ( );
272- }
264+ StreamerBase::writeToOutFile ( outfilePath_, format_, " a" , data_, columns_ );
265+ data_.clear ();
266+ numWriteEvents_ += 1 ;
273267}
274268
275269
@@ -356,6 +350,19 @@ size_t Streamer::getNumTables( void ) const
356350 return tables_.size ();
357351}
358352
353+ /* --------------------------------------------------------------------------*/
354+ /* *
355+ * @Synopsis Get number of write events in streamer. Useful for debugging and
356+ * performance measuerments.
357+ *
358+ * @Returns
359+ */
360+ /* ----------------------------------------------------------------------------*/
361+ size_t Streamer::getNumWriteEvents ( void ) const
362+ {
363+ return numWriteEvents_;
364+ }
365+
359366
360367string Streamer::getOutFilepath ( void ) const
361368{
0 commit comments