void setup()
 {
     mdperf_log.info() << "Creating random data..." << std::endl;
     data = new uint8_t[MD_PERF_DATASIZE];
     data[0] = MD_PERF_NUM_DEST_CHANNELS;
     for(uint32_t i = 1; i < MD_PERF_DATASIZE; ++i) {
         data[i] = rand() % 256;
     }
     mdperf_log.info() << "Creating MDPerformanceParticipants" << std::endl;
     m_participants = new MDPerformanceParticipant*[MD_PERF_NUM_PARTICIPANTS];
     for(uint32_t i = 0; i < MD_PERF_NUM_PARTICIPANTS; ++i) {
         m_participants[i] = new MDPerformanceParticipant;
     }
 }
Exemple #2
0
bool ConfigGroup::validate(ConfigNode node)
{
	if(!node.IsMap())
	{
		if(m_name.length() > 0)
		{
			config_log.error() << "Section '" << m_path
			                    << "' has key/value config variables.\n";
		}
		else
		{
			config_log.error() << "Config sections must be at root of config file.\n";
		}
		return false;
	}

	bool ok = true;
	for(auto it = node.begin(); it != node.end(); ++it)
	{
		string key = it->first.as<std::string>();

		auto found_var = m_variables.find(key);
		if(found_var != m_variables.end())
		{
			rtest r = found_var->second;
			if(!r(node))
			{
				config_log.info() << "In Section '" << m_path << "', attribute '"
				                  << key << "' did not match constraint (see error).\n";
				ok = false;
			}
			continue;
		}

		auto found_grp = m_children.find(key);
		if(found_grp != m_children.end())
		{
			if(!found_grp->second->validate(node[key]))
			{
				ok = false;
			}
			continue;
		}

		if(m_name.length() > 0)
		{
			config_log.error() << "Section '" << m_path
			                    << "' has no attribute named '" << key << "'.\n";
		}
		else
		{
			config_log.error() << "Section '" << key << "' is not a valid config category.\n";
		}
		ok = false;
	}
	return ok;
}
    void speed_test()
    {
        mdperf_log.info() << "Starting speed test I..." << std::endl;
        clock_t startTime = clock();
        while((clock() - startTime) / CLOCKS_PER_SEC < MD_PERF_TIME) {
            for(uint32_t i = 0; i < MD_PERF_NUM_PARTICIPANTS; ++i) {
                m_participants[i]->spam();
            }
        }
        mdperf_log.info() << "Test over. Averaging messages..." << std::endl;
        double num_messages = 0;
        for(uint32_t i = 0; i < MD_PERF_NUM_PARTICIPANTS; ++i) {
            num_messages += double(m_participants[i]->num_messages) / double(MD_PERF_NUM_PARTICIPANTS);
        }

        mdperf_log.info() << "An average of " << num_messages << " messages were processed. "
                          "this comes out to be " << num_messages / MD_PERF_TIME << " messages/second" << std::endl;
    }
 void cleanup()
 {
     mdperf_log.info() << "Cleaning up..." << std::endl;
     for(uint32_t i = 0; i < MD_PERF_NUM_PARTICIPANTS; ++i) {
         delete m_participants[i];
     }
     delete [] m_participants;
     delete [] data;
 }
		MDPerformanceTest()
		{
			mdperf_log.info() << "Starting perf test..." << std::endl;
			setup();
			speed_test();
			cleanup();
			setup();
			speed_test_no_memcpy();
			cleanup();
		}
Exemple #6
0
void KeyedConfigList::print_keys()
{
	ostream& out = config_log.info();
	out << "Expected value in '" << m_name << "',\n"
	    << "    Candidates for attribute '" << m_key << "' are:\n";
	for(auto it = m_children.begin(); it != m_children.end(); ++it)
	{
		out << "        " << it->second->get_name() << "\n";
	}
	out << "\n";
}