Esempio n. 1
0
void Profiler::setCaptureReport(bool captureReport)
{
    if (!m_capture_report && captureReport)
    {
        m_capture_report = true;
        m_first_capture_sweep = true;
        m_first_gpu_capture_sweep = true;
        // TODO: a 20 MB hardcoded buffer for now. That should amply suffice for
        // all reasonable purposes. But it's not too clean to hardcode
        m_capture_report_buffer = new StringBuffer(20 * 1024 * 1024);
        m_gpu_capture_report_buffer = new StringBuffer(20 * 1024 * 1024);
    }
    else if (m_capture_report && !captureReport)
    {
        // when disabling capture to file, flush captured data to a file
        {
            std::ofstream filewriter(file_manager->getUserConfigFile("profiling.csv").c_str(), std::ios::out | std::ios::binary);
            const char* str = m_capture_report_buffer->getRawBuffer();
            filewriter.write(str, strlen(str));
        }
        {
            std::ofstream filewriter(file_manager->getUserConfigFile("profiling_gpu.csv").c_str(), std::ios::out | std::ios::binary);
            const char* str = m_gpu_capture_report_buffer->getRawBuffer();
            filewriter.write(str, strlen(str));
        }

        m_capture_report = false;

        delete m_capture_report_buffer;
        m_capture_report_buffer = NULL;

        delete m_gpu_capture_report_buffer;
        m_gpu_capture_report_buffer = NULL;
    }
}
Esempio n. 2
0
//returns count of openings written to book 'filename'
uint32_t openingswriter(const char *filename) {
	FILE *_file=fopen(filename,"r");
	if(!_file)
		return 0;
	opening *_opening=(opening *)malloc(sizeof(opening));
	uint8_t string[4*MAXMOVES+1],_count=0;
	while(fscanf(_file,"%[^\n]\n",string)!=EOF) {
		filewriter("openings.dat",string);
		_count++;
	}
	fclose(_file);
	free(_opening);
	return _count;
}