#include "LoadTimeInitializer.h" #include "utils.h" using namespace std; LoadTimeInitializer g_load_time_initializer; LoadTimeInitializer::LoadTimeInitializer() //will be called when library is loaded { ConvertChar::init(); m_sumNumReads = 0; m_sumSquareNumReads = 0; m_sumNumHaplotypes = 0; m_sumSquareNumHaplotypes = 0; m_sumNumTestcases = 0; m_sumNumDoubleTestcases = 0; m_sumSquareNumTestcases = 0; m_sumReadLengths = 0; m_sumHaplotypeLengths = 0; m_sumProductReadLengthHaplotypeLength = 0; m_sumSquareProductReadLengthHaplotypeLength = 0; m_maxNumTestcases = 0; m_num_invocations = 0; m_compute_time = 0; m_data_transfer_time = 0; m_bytes_copied = 0; m_filename_to_fptr.clear(); initialize_function_pointers(); cout.flush(); } void LoadTimeInitializer::print_profiling() { double mean_val; cout << "Compute time "<::iterator mI = m_filename_to_fptr.find(filename); ofstream* fptr = 0; if(mI == m_filename_to_fptr.end()) { m_filename_to_fptr[filename] = new ofstream(); fptr = m_filename_to_fptr[filename]; fptr->open(filename.c_str(), to_append ? ios::app : ios::out); assert(fptr->is_open()); } else fptr = (*mI).second; //ofstream fptr; //fptr.open(filename.c_str(), to_append ? ofstream::app : ofstream::out); (*fptr) << s; if(add_newline) (*fptr) << "\n"; //fptr.close(); } void LoadTimeInitializer::debug_close() { for(map::iterator mB = m_filename_to_fptr.begin(), mE = m_filename_to_fptr.end(); mB != mE;mB++) { (*mB).second->close(); delete (*mB).second; } m_filename_to_fptr.clear(); } void LoadTimeInitializer::dump_sandbox(testcase& tc, unsigned tc_idx, unsigned numReads, unsigned numHaplotypes) { unsigned haplotypeLength = tc.haplen; unsigned readLength = tc.rslen; ofstream& dumpFptr = m_sandbox_fptr; for(unsigned k=0;k