Ejemplo n.º 1
0
void connection::update_local_threshold(boost::posix_time::time_duration duration, std::size_t bytes_sent)
{
	// Move the oob threshold up or down in proportion to the difference between the target latency and
	// how long this operation took
	// We cap any increase at the amount of data sent for this operation. This is to prevent
	// the threshold from overshooting too much on lightly loaded short-thin links.
	local_oob_threshold_ += std::min(double((target_latency.total_milliseconds() - duration.total_milliseconds()))
	                                 / double(target_latency.total_milliseconds()) * local_oob_threshold_,
	                                 double(bytes_sent));
	local_oob_threshold_ = std::max(local_oob_threshold_, 1.0);
}
Ejemplo n.º 2
0
// Provide an update on how long the simulation is expected to take to the user
void Simulator::timingUpdate(boost::posix_time::time_duration lastCycleLength) {
    long total = finishTime.minus(startTime, config->getInt("simulationinterval"));
    long complete = currTime.minus(startTime, config->getInt("simulationinterval"));
    long togo = finishTime.minus(currTime, config->getInt("simulationinterval"));
    
    std::cout << "Simulation progress: " << std::endl
              << " - Start  : " << startTime.toString() << std::endl
              << " - Now at : " << currTime.toString() << std::endl
              << " - End    : " << finishTime.toString() << std::endl
              << " - " << std::setprecision(2) << double(complete)/double(total)*100 << "% complete, approximately " 
              << utility::timeDisplay(togo*(long)(lastCycleLength.total_milliseconds())) << " remaining." << std::endl;
}
Ejemplo n.º 3
0
static void on_hello_response(const std::string& name, fscp::server& server, const fscp::server::ep_type& sender, const boost::posix_time::time_duration& time_duration, bool success)
{
	if (!success)
	{
		std::cout << "[" << name << "] Received no HELLO response from " << sender << " after " << time_duration.total_milliseconds() << " ms" << std::endl;
	} else
	{
		std::cout << "[" << name << "] Received HELLO response from " << sender << " (" << time_duration.total_milliseconds() << " ms)" << std::endl;

		server.async_introduce_to(sender);
	}
}
Ejemplo n.º 4
0
value_visitor::result_type
value_visitor::operator()(const date_t& value)
{
	static const date_t EPOCH(boost::gregorian::date(1970, 1, 1));
	const boost::posix_time::time_duration duration = value - EPOCH;
	if (duration.seconds() == 0 && duration.fractional_seconds() == 0)
	{
		push_back<std::int8_t>('K');
		push_back<std::int32_t>(duration.total_seconds() / 60);
	}
	else
	{
		push_back<std::int8_t>('J');
		push_back<std::int64_t>(duration.total_milliseconds());
	}
}
Ejemplo n.º 5
0
string current_time_string()  {

  stringstream sstream;
  
  boost::posix_time::ptime now = boost::posix_time::
    microsec_clock::local_time();

    const boost::posix_time::time_duration td = now.time_of_day();
    const long hours        = td.hours();
    const long minutes      = td.minutes();
    const long seconds      = td.seconds();
    const long milliseconds = td.total_milliseconds() -
                              ((hours * 3600 + minutes * 60 + seconds) *
			       1000);
    char buf[40];
    sprintf(buf, "%02ld:%02ld:%02ld.%03ld", 
        hours, minutes, seconds, milliseconds);

    return string(buf);
}
Ejemplo n.º 6
0
void curl::set_connect_timeout(const boost::posix_time::time_duration& timeout)
{
    set_option(CURLOPT_CONNECTTIMEOUT_MS, timeout.total_milliseconds());
}
Ejemplo n.º 7
0
 inline boost::uint64_t hash_value(const boost::posix_time::time_duration& value, boost::uint64_t seed)
 {
     return hash_value((boost::int64_t)value.total_milliseconds(), seed);
 }