예제 #1
0
void
ACE_Throughput_Stats::dump_throughput (const ACE_TCHAR *msg,
                                       ACE_UINT32 sf,
                                       ACE_UINT64 elapsed_time,
                                       ACE_UINT32 samples_count)
{
#ifndef ACE_NLOGGING
  double seconds =
# if defined ACE_LACKS_LONGLONG_T
    elapsed_time / sf;
#elif  defined (ACE_LACKS_UNSIGNEDLONGLONG_T)
    static_cast<double> (ACE_UINT64_DBLCAST_ADAPTER (
                           ACE_U_LongLong(elapsed_time / sf)));
# else  /* ! ACE_LACKS_LONGLONG_T */
    static_cast<double> (ACE_UINT64_DBLCAST_ADAPTER (elapsed_time / sf));
# endif /* ! ACE_LACKS_LONGLONG_T */
  seconds /= ACE_HR_SCALE_CONVERSION;

  const double t_avg = samples_count / seconds;

  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("%s throughput: %.2f (events/second)\n"),
              msg, t_avg));
#else
  ACE_UNUSED_ARG (msg);
  ACE_UNUSED_ARG (sf);
  ACE_UNUSED_ARG (elapsed_time);
  ACE_UNUSED_ARG (samples_count);
#endif /* ACE_NLOGGING */
}
예제 #2
0
  this->usec (this->usec () - 1);
  this->normalize ();
  return *this;
}

#if defined (ACE_WIN32)
/// Static constant to remove time skew between FILETIME and POSIX
/// time.  POSIX and Win32 use different epochs (Jan. 1, 1970 v.s.
/// Jan. 1, 1601).  The following constant defines the difference
/// in 100ns ticks.
///
/// In the beginning (Jan. 1, 1601), there was no time and no computer.
/// And Bill said: "Let there be time," and there was time....
# if defined (ACE_LACKS_LONGLONG_T)
const ACE_U_LongLong ACE_Time_Value::FILETIME_to_timval_skew =
ACE_U_LongLong (0xd53e8000, 0x19db1de);
# else
const DWORDLONG ACE_Time_Value::FILETIME_to_timval_skew =
ACE_INT64_LITERAL (0x19db1ded53e8000);
# endif

///  Initializes the ACE_Time_Value object from a Win32 FILETIME
ACE_Time_Value::ACE_Time_Value (const FILETIME &file_time)
{
  // // ACE_OS_TRACE ("ACE_Time_Value::ACE_Time_Value");
  this->set (file_time);
}

void ACE_Time_Value::set (const FILETIME &file_time)
{
  //  Initializes the ACE_Time_Value object from a Win32 FILETIME
static
u_long
test_ace_u_longlong (void)
{
    u_long errors = 0;

    ACE_U_LongLong ull1 (0x21,1);
    errors += check_ace_u_longlong (ACE_TEXT ("ull1"), ull1, 1, 0x21);

    ACE_U_LongLong ull2 (0x20,2);
    errors += check_ace_u_longlong (ACE_TEXT ("ull2"), ull2, 2, 0x20);

    ull2 -= ull1;
    errors += check_ace_u_longlong (ACE_TEXT ("ull2"), ull2, 0, 0xfffffffful);

    ull2 += ull1;
    errors += check_ace_u_longlong (ACE_TEXT ("ull2"), ull2, 2, 0x20);

    ACE_U_LongLong ull3 = ull1 + ull1;
    errors += check_ace_u_longlong (ACE_TEXT ("ull3"), ull3, 2, 0x42);

    ACE_U_LongLong ull4 = ACE_U_LongLong (0x1111, 0) -
                          ACE_U_LongLong (0x1112, 0);
    errors += check_ace_u_longlong (ACE_TEXT ("ull4"), ull4, 0xfffffffful, 0xfffffffful);

    ACE_U_LongLong ull5 = ACE_U_LongLong (0x1111, 1) -
                          ACE_U_LongLong (0x1112, 0);
    errors += check_ace_u_longlong (ACE_TEXT ("ull5"), ull5, 0, 0xfffffffful);

    ++ull5;
    errors += check_ace_u_longlong (ACE_TEXT ("ull5"), ull5, 1, 0);

    ACE_U_LongLong ull6 = ull2 + ACE_U_LongLong (0, 1);
    errors += check_ace_u_longlong (ACE_TEXT ("ull6"), ull6, 3, 0x20);

    ull6 += ACE_U_LongLong (0xffffffff, 0xfff0);
    errors += check_ace_u_longlong (ACE_TEXT ("ull6"), ull6, 0xfff4, 0x1f);

    ++ull6;
    errors += check_ace_u_longlong (ACE_TEXT ("ull6"), ull6, 0xfff4, 0x20);

    // The hi part of ull6 will be lost in the following, because
    // the quotient has only 32 bits.
    errors += check_ace_u_longlong (ACE_TEXT ("ull6 / 1"),
                                    (ACE_U_LongLong) (ull6 / 1u),
                                    0, 0x20);

    // There's apparently a small loss in precision in
    // ACE_U_LongLong::operator/.  It calculates
    // ull6 / 0xd0000 as 0x13b013b4 instead of 0x13b04ec4.
    errors += check_ace_u_longlong (ACE_TEXT ("ull6 / 0x10000 / 0xd"),
                                    (ACE_U_LongLong) (ull6 / 0x10000u / 0xd),
                                    0, 0x13b04ec4);

    errors += check_ace_u_longlong (ACE_TEXT ("ull6 % 5"),
                                    (ACE_U_LongLong) (ull6 % 5),
                                    0, 1);

    errors += check_ace_u_longlong (ACE_TEXT ("ull6 % 0x20007"),
                                    (ACE_U_LongLong) (ull6 % 0x20007),
                                    0, 0x3f63);

    ACE_U_LongLong ull7 (12);
    ull7 *= 3125;
    errors += check_ace_u_longlong (ACE_TEXT ("12 * 3125"),
                                    ull7,
                                    0, 37500);

    ull7 *= 100;
    errors += check_ace_u_longlong (ACE_TEXT ("37500 * 100"),
                                    ull7,
                                    0, 3750000);

    errors += check_ace_u_longlong (ACE_TEXT ("3750000 << 16"),
                                    ull7 << 16 ,
                                    0x39, 0x38700000);

    errors += check_ace_u_longlong (ACE_TEXT ("3750000 >> 16"),
                                    ull7 >> 16,
                                    0, 0x39);

    ull7 <<= 32;
    errors += check_ace_u_longlong (ACE_TEXT ("3750000 <<= 32"),
                                    ull7,
                                    3750000, 0);

    ull7 >>= 12;
    errors += check_ace_u_longlong (ACE_TEXT ("3750000 <<= 32 >>= 15"),
                                    ull7,
                                    0x393, 0x87000000);

    ACE_U_LongLong ull8 (0x0f0f, 0xf0f0);
    ACE_U_LongLong ull9 (0xf0f0, 0xf0f0);
    ull8 |= ull9;
    errors += check_ace_u_longlong (ACE_TEXT ("ull8 |= ull9"),
                                    ull8,
                                    0xf0f0, 0xffff);

    ull9.lo (0x5678);
    ull9.hi (0x1234);
    ull8 &= ull9;
    errors += check_ace_u_longlong (ACE_TEXT ("ull8 &= 0x12345678"),
                                    ull9,
                                    0x1234, 0x5678);

    return errors;
}