Exemplo n.º 1
0
    void report_time(const server& s, boost::posix_time::time_duration time)
    {
        server_times_.update_resp_time(s.get_id(), time.total_microseconds());
        uint32_t new_reqs_sec = server_times_.reqs_sec(s);

        update_server(s, new_reqs_sec);
    }
Exemplo n.º 2
0
std::size_t select::wait( boost::posix_time::time_duration timeout )
{
    unsigned int sec = timeout.total_seconds();
	unsigned int nanosec = ( static_cast< unsigned int >( timeout.total_microseconds() ) - sec * 1000000 ) * 1000;
//     std::cerr << "select wait " << sec << " , " << nanosec << std::endl;
    return wait( sec, nanosec );
}
void Tac()
{
 	timeEnd_ = boost::posix_time::microsec_clock::local_time() - timeIni	;
	timeEnd=(double)timeEnd_.total_microseconds() ;

	//std::cout << timeEnd<< std::endl;
}
Exemplo n.º 4
0
std::string HighResSecondsString(const boost::posix_time::time_duration& duration)
{
  std::stringstream os;
  
  if (duration.total_microseconds() < 100000)
  {
    os << std::fixed << std::setprecision(3);
    os << (duration.total_microseconds() / 1000.0 ) << "ms";
  }
  else
  {
    os << std::fixed << std::setprecision(2);
    os << (duration.total_microseconds() / 1000000.0) << "s";
  }
  
  return os.str();
}
Exemplo n.º 5
0
boost::posix_time::ptime sj::ceiling(boost::posix_time::ptime dt,
                                     boost::posix_time::time_duration dur)
{
    time_duration dt_dur = dt - EPOCH;
    time_duration::tick_type dt_ms = dt_dur.total_microseconds();
    time_duration::tick_type dur_ms = dur.total_microseconds();
    time_duration::tick_type modified = (dt_ms + dur_ms - 1) / dur_ms;
    return EPOCH + microsec(modified * dur_ms);
}
Exemplo n.º 6
0
boost::int64_t DataStorage::getTimestamp()
{
    //init the starttime as it is needed for the first time
    if (!start_)
    {
        start_.reset(new boost::posix_time::ptime(boost::posix_time::microsec_clock::local_time()));
    }

    boost::posix_time::time_duration const diff = boost::posix_time::microsec_clock::local_time() - *start_;
    return diff.total_microseconds();
}
Exemplo n.º 7
0
inertial::value::value( boost::posix_time::time_duration decay, unsigned int maximum ) : decay_( decay.total_microseconds() ), maximum_( maximum ), value_( 0 ) {}
Exemplo n.º 8
0
 unsigned int NetworkActivity::getCurrentTime()
 {
     boost::posix_time::time_duration const diff = boost::posix_time::microsec_clock::local_time() - profilingStart_;
     return diff.total_microseconds();
 }
Exemplo n.º 9
0
static UHD_INLINE double from_time_dur(const pt::time_duration &time_dur){
    return 1e-6*time_dur.total_microseconds();
}
Exemplo n.º 10
0
void AutomaticGraphicsLevelManager::averageTimePerFrameUpdated(const boost::posix_time::time_duration timePerFrame)
{
	//Convert microseconds per frame to fps.
	checkFps(1000000.0f / timePerFrame.total_microseconds());
}
Exemplo n.º 11
0
void run( S* stream )
{
    static const unsigned int timeSize = 12;
    boost::mt19937 generator;
    boost::uniform_real< float > distribution( 0, 1 );
    boost::variate_generator< boost::mt19937&, boost::uniform_real< float > > random( generator, distribution );
    comma::uint64 count = 0;
    comma::uint64 dropped_count = 0;
    double compression = 0;
    velodyne::packet packet;
    comma::signal_flag isShutdown;
    velodyne::scan_tick tick;
    comma::uint32 scan_id = 0;
    while( !isShutdown && std::cin.good() && !std::cin.eof() && std::cout.good() && !std::cout.eof() )
    {
        const char* p = velodyne::impl::stream_traits< S >::read( *stream, sizeof( velodyne::packet ) );
        if( p == NULL ) { break; }
        ::memcpy( &packet, p, velodyne::packet::size );
        if( tick.is_new_scan( packet ) ) { ++scan_id; } // quick and dirty
        boost::posix_time::ptime timestamp = stream->timestamp();
        if( scan_rate ) { scan.thin( packet, *scan_rate, angularSpeed( packet ) ); }
        if( !scan_rate || !scan.empty() )
        {
            if( focus ) { velodyne::thin::thin( packet, *focus, *db, angularSpeed( packet ), random ); }
            if( rate ) { velodyne::thin::thin( packet, *rate, random ); }
        }
        const boost::posix_time::ptime base( snark::timing::epoch );
        const boost::posix_time::time_duration d = timestamp - base;
        comma::int64 seconds = d.total_seconds();
        comma::int32 nanoseconds = static_cast< comma::int32 >( d.total_microseconds() % 1000000 ) * 1000;
        if( outputRaw ) // real quick and dirty
        {
            static boost::array< char, 16 + timeSize + velodyne::packet::size + 4 > buf;
            static const boost::array< char, 2 > start = {{ -78, 85 }}; // see QLib::Bytestreams::GetDefaultStartDelimiter()
            static const boost::array< char, 2 > end = {{ 117, -97 }}; // see QLib::Bytestreams::GetDefaultStartDelimiter()
            ::memcpy( &buf[0], &start[0], 2 );
            ::memcpy( &buf[0] + buf.size() - 2, &end[0], 2 );
            ::memcpy( &buf[0] + 16, &seconds, 8 );
            ::memcpy( &buf[0] + 16 + 8, &nanoseconds, 4 );
            ::memcpy( &buf[0] + 16 + 8 + 4, &packet, velodyne::packet::size );
            if( publisher ) { publisher->write( &buf[0], buf.size() ); }
            else if( publisher_udp_socket ) { publisher_udp_socket->send_to( boost::asio::buffer( &buf[0], buf.size() ), udp_destination ); }
            else { std::cout.write( &buf[0], buf.size() ); }
        }
        else
        {
            // todo: certainly rewrite with the proper header using comma::packed
            static char buf[ timeSize + sizeof( comma::uint16 ) + velodyne::thin::maxBufferSize ];
            comma::uint16 size = velodyne::thin::serialize( packet, buf + timeSize + sizeof( comma::uint16 ), scan_id );
            bool empty = size == ( sizeof( comma::uint32 ) + 1 ); // todo: atrocious... i.e. packet is not empty; refactor!!!
            if( !empty )
            {
                size += timeSize;
                ::memcpy( buf, &size, sizeof( comma::uint16 ) );
                size += sizeof( comma::uint16 );
                ::memcpy( buf + sizeof( comma::uint16 ), &seconds, sizeof( comma::int64 ) );
                ::memcpy( buf + sizeof( comma::uint16 ) + sizeof( comma::int64 ), &nanoseconds, sizeof( comma::int32 ) );
                if( publisher ) { publisher->write( buf, size ); }
                else if( publisher_udp_socket ) { publisher_udp_socket->send_to( boost::asio::buffer( buf, size ), udp_destination ); }
                else { std::cout.write( buf, size ); }
            }
            else
            {
                ++dropped_count;
            }
            if( verbose )
            {
                ++count;
                compression = 0.9 * compression + 0.1 * ( empty ? 0.0 : double( size + sizeof( comma::int16 ) ) / ( velodyne::packet::size + timeSize ) );
                if( count % 10000 == 0 ) { std::cerr << "velodyne-thin: processed " << count << " packets; dropped " << ( double( dropped_count ) * 100. / count ) << "% full packets; compression rate " << compression << std::endl; }
            }
        }
    }
    if( publisher ) { publisher->close(); }
    std::cerr << "velodyne-thin: " << ( isShutdown ? "signal received" : "no more data" ) << "; shutdown" << std::endl;
}
Exemplo n.º 12
0
 /*!
   \param time The time point to truncate.
   \param unit The unit of time to truncate the time point to.
   \return The time point truncated to the specified <i>unit</i>.
 */
 inline boost::posix_time::ptime Truncate(const boost::posix_time::ptime& time,
     boost::posix_time::time_duration unit) {
   return time - boost::posix_time::microseconds(
     time.time_of_day().total_microseconds() % unit.total_microseconds());
 }
Exemplo n.º 13
0
double CalculateSpeed(long long bytes, const boost::posix_time::time_duration& duration)
{
  double seconds = duration.total_microseconds() / 1000000.0;
  return seconds == 0.0 ? bytes : bytes / seconds;
}