Example #1
0
bool CTestTlsObjectApp::Thread_Run(int /*idx*/)
{
    try {
        RunTest();
        RunTest();
        RunTest();
        return true;
    }
    NCBI_CATCH_ALL("Test failed");
    size_t total, resident, shared;
    if ( GetMemoryUsage(&total, &resident, &shared) ) {
        ERR_POST("Alloc: "<<alloc_count.Get()<<" "<<object_count.Get()<<'\n'<<
                 "Memory: "<<total<<" "<<resident<<" "<<shared);
    }
    return false;
}
Example #2
0
void check_cnts(size_t expected = 0,
                size_t expected_static = 0)
{
    if ( expected == ~0u ) {
        expected = 0;
    }
    else {
        expected = 1;
    }
    if ( expected == 0 ) {
        if ( alloc_count.Get() != expected-expected_static )
            ERR_FATAL("alloc_count: "<<alloc_count.Get());
        if ( object_count.Get() != expected )
            ERR_FATAL("object_count: "<<object_count.Get());
    }
    _VERIFY(!sx_HaveLastNewPtr());
}
Example #3
0
void message(const char* msg,
             const char* msg1, double t1,
             const char* msg2, double t2,
             size_t COUNT)
{
    if ( 0 ) {
        LOG_POST(msg
                 <<'\n'<<setw(40) << msg1 << ": "<< t1 * 1e9/(double)COUNT << " usec"
                 <<'\n'<<setw(40) << msg2 << ": "<< t2 * 1e9/(double)COUNT << " usec");
    }
    size_t total, resident, shared;
    if ( GetMemoryUsage(&total, &resident, &shared) ) {
        max_total = max(max_total, total);
        max_resident = max(max_resident, resident);
        max_shared = max(max_shared, shared);
        if ( 0 ) {
            LOG_POST("Alloc: "<<alloc_count.Get()<<
                     " "<<object_count.Get()<<'\n'<<
                     "Current memory: "<<total<<" "<<resident<<" "<<shared);
        }
    }
}
Example #4
0
void check_operations()
{
    _ASSERT(current_step.Get() == total_steps);
    typedef map<void*, size_t> TAllocated;
    TAllocated allocated;
    size_t count = operation_count.Get();
    for ( size_t i = 0; i < count; ++i ) {
        const SOperation& op = operations[i];
        _ASSERT(op.type != 0);
        void* ptr = op.ptr;
        if ( op.type > 0 ) {
            void* end = (char*)ptr + op.size;
            TAllocated::iterator it1 = allocated.lower_bound(ptr);
            TAllocated::iterator it2 = allocated.lower_bound(end);
            _ASSERT(it1 == it2);
            allocated[ptr] = op.size;
        }
        else {
            _ASSERT(allocated.find(ptr) != allocated.end());
            allocated.erase(ptr);
        }
    }
    _ASSERT(allocated.empty());
}
Example #5
0
void CRequestContext::x_UpdateSubHitID(bool increment)
{
    static CAtomicCounter s_DefaultSubHitCounter;

    _ASSERT(IsSetHitID());

    // Use global sub-hit counter for default hit id to prevent
    // duplicate phids in different threads.
    m_SubHitIDCache = GetHitID();

    unsigned int sub_hit_id;
    if (m_SubHitIDCache == GetDiagContext().GetDefaultHitID()) {
        sub_hit_id = (unsigned int)(increment ? s_DefaultSubHitCounter.Add(1) :
            s_DefaultSubHitCounter.Get());
    }
    else {
        if ( increment ) ++m_SubHitID;
        sub_hit_id = m_SubHitID;
    }

    // Cache the string so that C code can use it.
    m_SubHitIDCache += "." + NStr::NumericToString(sub_hit_id);
}