コード例 #1
0
ファイル: tick_count_timer.cpp プロジェクト: 0xDEC0DE8/mcsema
 // Subtract one time from another.
 static duration_type subtract(const time_type& t1, const time_type& t2)
 {
   // DWORD tick count values can wrap (see less_than() below). We'll convert
   // to a duration by taking the absolute difference and adding the sign
   // based on which is the "lesser" absolute time.
   return duration_type(less_than(t1, t2)
       ? -static_cast<LONG>(t2.ticks_ - t1.ticks_)
       : static_cast<LONG>(t1.ticks_ - t2.ticks_));
 }
コード例 #2
0
    InItrT get(InItrT& from,
               InItrT& to,
               std::ios_base& a_ios,
               duration_type& dd) const
    {
        // skip leading whitespace
        while(std::isspace(*from) && from != to) {
            ++from;
        }

        /* num_get.get() will always consume the first character if it
         * is a sign indicator (+/-). Special value strings may begin
         * with one of these signs so we'll need a copy of it
         * in case num_get.get() fails. */
        char_type c = '\0';
        // TODO Are these characters somewhere in the locale?
        if(*from == '-' || *from == '+') {
            c = *from;
        }
        typedef std::num_get<CharT, InItrT> num_get;
        typename duration_type::duration_rep_type val = 0;
        std::ios_base::iostate err = std::ios_base::goodbit;

        if (std::has_facet<num_get>(a_ios.getloc())) {
            from = std::use_facet<num_get>(a_ios.getloc()).get(from, to, a_ios, err, val);
        }
        else {
            num_get* ng = new num_get();
            std::locale l = std::locale(a_ios.getloc(), ng);
            a_ios.imbue(l);
            from = ng->get(from, to, a_ios, err, val);
        }
        if(err & std::ios_base::failbit) {
            typedef typename special_values_parser_type::match_results match_results;
            match_results mr;
            if(c == '-' || c == '+') { // was the first character consumed?
                mr.cache += c;
            }
            m_sv_parser.match(from, to, mr);
            if(mr.current_match == match_results::PARSE_ERROR) {
                boost::throw_exception(std::ios_base::failure("Parse failed. No match found for '" + mr.cache + "'"));
                BOOST_DATE_TIME_UNREACHABLE_EXPRESSION(return from); // should never reach
            }
            dd = duration_type(static_cast<special_values>(mr.current_match));
        }
コード例 #3
0
ファイル: cache.cpp プロジェクト: jgphpc/stream-clean
int main(int argc, char** argv) {
    // make buffer large enough for 64 MB (2^6)
    const auto buffer_len = 1024/sizeof(value_type)*1024*(1<<6);
    const auto buffer_size = sizeof(value_type)*buffer_len;

    value_type *buffer;
    posix_memalign((void**)&buffer, 64, buffer_size);
    std::fill(buffer, buffer+buffer_len, value_type{0});

    std::vector<double> times;
    std::vector<size_t> bytes;

    auto onek  = 1024ul/sizeof(value_type);
    auto onem  = onek * 1024ul;
    auto upper = buffer_len;
    auto sizes = generate_range(256/sizeof(value_type), upper);

    for(auto n: sizes) {
        auto num_iters = buffer_len * 16 / n;
        do_work(buffer, n);
        auto start = clock_type::now();
        for(auto i=0; i<num_iters; ++i) {
            do_work(buffer, n);
        }
        auto time_taken = duration_type(clock_type::now()-start).count();
        bytes.push_back(num_iters*n*sizeof(value_type));
        times.push_back(time_taken);
    }
    printf("%15s%15s%15s\n", "bytes", "human", "bandwidth GB/s");
    for(auto i=0; i<times.size(); ++i) {
        auto b = sizeof(value_type)*sizes[i];
        printf("%15ld%15s%15.2f\n",
               b,
               to_string(b).c_str(),
               bytes[i]/(float)times[i]*1e-9f);
    }

    free(buffer);
}
コード例 #4
0
ファイル: main.cpp プロジェクト: KerwinMa/test
	// Subtract one time from another.
	static duration_type subtract(const time_type& t1, const time_type& t2)
	{
		return duration_type(t1 - t2);
	}
コード例 #5
0
ファイル: time_duration.hpp プロジェクト: ASMlover/study
 duration_type operator*=(int divisor)
 {
   ticks_ = ticks_ * divisor;
   return duration_type(ticks_);
 }
コード例 #6
0
ファイル: time_duration.hpp プロジェクト: ASMlover/study
 //! Multiplication operations an a duration with an integer
 duration_type operator*(int rhs) const
 {
   return duration_type(ticks_ * rhs);
 }
コード例 #7
0
ファイル: time_duration.hpp プロジェクト: ASMlover/study
 duration_type operator+=(const duration_type& d)
 {
   ticks_ = ticks_ + d.ticks_;
   return duration_type(ticks_);
 }
コード例 #8
0
ファイル: util.cpp プロジェクト: chenbk85/DNNLM
void Timer::reset(int i) { m_total[i] = duration_type(); }
コード例 #9
0
 // Subtract one time from another.
 time_t_traits::duration_type time_t_traits::subtract(const time_type& t1,
                                                      const time_type& t2)
 {
     return duration_type(t1 - t2);
 }
コード例 #10
0
 bool frontBlock(T& t, boost::uint32_t timeout) const
 {
     return frontBlock(t, duration_type(timeout));
 }
コード例 #11
0
 bool pop(T& t, boost::uint32_t timeout)
 {
     return pop(t, duration_type(timeout));
 }
コード例 #12
0
ファイル: test_timer.cpp プロジェクト: TorstenRobitzki/Sioux
 timer::duration_type timer::expires_from_now() const
 {
     return duration_type();
 }