Example #1
0
int main( int ac, char * av[] )
{
    int success = 1;

    success &= performance_test( int8_t() );
    success &= performance_test( int16_t() );
    success &= performance_test( int32_t() );
    success &= performance_test( int64_t() );

    success &= performance_test( uint8_t() );
    success &= performance_test( uint16_t() );
    success &= performance_test( uint32_t() );
    success &= performance_test( uint64_t() );

    return success ? 0 : 1 ;
}
Example #2
0
// -----------------------------------------------------------------------------
int main()
{
    try
    {
        auto reference_datum_path = get__reference_datum_path ();
        auto action_logs_path = reference_datum_path + L"test-results\\C\\";

        wprintf(L"m3_hron - running test cases\r\n");

        if (!directory_exists (reference_datum_path))
        {
            wprintf(L"Exiting due to missing reference datum directory (%s)\r\n", reference_datum_path.c_str ());
            return 999;
        }

        if (!directory_exists (action_logs_path) && !create_directory (action_logs_path))
        {
            wprintf(L"Exiting due to missing action log directory couldn't be created (%s)\r\n", action_logs_path.c_str ());
            return 999;
        }

        unit_test           (reference_datum_path, action_logs_path);
        correctness_test    (reference_datum_path, action_logs_path);
        performance_test    (reference_datum_path, action_logs_path);

        return 0;
    }
    catch (exitcode_exception const & e)
    {
        return e.exitcode;
    }
    catch (std::exception const & e)
    {
        wprintf(L"Exiting due to error: %S\r\n", e.what ());
        return 999;
    }
    catch (...)
    {
        wprintf(L"Exiting due to unrecognized error\r\n");
        return 999;
    }
}
Example #3
0
int main()
{
    //init();
#ifdef _DEBUG
    performance_test();
    unittest();
#endif

    int n = 0;
    printf("请输入要判断是否为素数的正整数:");
    scanf_s("%d", &n);

    int b = is_prime(n);
    if (b != 0)
    {
        printf("%d是素数\n", n);
    }
    else
    {
        printf("%d不是素数\n", n);
    }

    return 0;
}
Example #4
0
int
run_main (int argc, ACE_TCHAR *argv[])
{
    ACE_START_TEST (ACE_TEXT ("Map_Test"));
    ACE_LOG_MSG->clr_flags (ACE_Log_Msg::VERBOSE_LITE);

    size_t table_size = ACE_MAX_ITERATIONS / 2;
    size_t iterations = ACE_MAX_ITERATIONS;
    size_t functionality_tests = 1;

    if (argc > 1)
        functionality_tests = ACE_OS::atoi (argv[1]);

    if (argc > 2)
        table_size = ACE_OS::atoi (argv[2]);

    if (argc > 3)
        iterations = ACE_OS::atoi (argv[3]);

    MAP_MANAGER_ADAPTER map1 (table_size);
    HASH_MAP_MANAGER_ADAPTER map2 (table_size);
    ACTIVE_MAP_MANAGER_ADAPTER map3 (table_size);

    if (functionality_tests)
    {
        // Functionality test of the maps.
        ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nMap Manager functionality test\n")));
        functionality_test (map1, iterations);

        ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nHash Map Manager functionality test\n")));
        functionality_test (map2, iterations);

        ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nActive Map Manager functionality test\n")));
        functionality_test (map3, iterations);

        ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")));
    }

    // Performance test of the maps.
    KEY *keys = new KEY[iterations];

    // Map Manager
    performance_test (&insert_test,
                      map1,
                      iterations,
                      keys,
                      table_size,
                      ACE_TEXT ("Map Manager (insert test)"));
    performance_test (&find_test,
                      map1,
                      iterations,
                      keys,
                      table_size,
                      ACE_TEXT ("Map Manager (find test)"));
    performance_test (&unbind_test,
                      map1,
                      iterations,
                      keys,
                      table_size,
                      ACE_TEXT ("Map Manager (unbind test)"));

    ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")));

    // Hash Map Manager
    performance_test (&insert_test,
                      map2,
                      iterations,
                      keys,
                      table_size,
                      ACE_TEXT ("Hash Map Manager (insert test)"));
    performance_test (&find_test,
                      map2,
                      iterations,
                      keys,
                      table_size,
                      ACE_TEXT ("Hash Map Manager (find test)"));
    performance_test (&unbind_test,
                      map2,
                      iterations,
                      keys,
                      table_size,
                      ACE_TEXT ("Hash Map Manager (unbind test)"));

    ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")));

    // Active Map Manager
    performance_test (&insert_test,
                      map3,
                      iterations,
                      keys,
                      table_size,
                      ACE_TEXT ("Active Map Manager (insert test)"));
    performance_test (&find_test,
                      map3,
                      iterations,
                      keys,
                      table_size,
                      ACE_TEXT ("Active Map Manager (find test)"));
    performance_test (&unbind_test,
                      map3,
                      iterations,
                      keys,
                      table_size,
                      ACE_TEXT ("Active Map Manager (unbind test)"));

    delete[] keys;

    ACE_LOG_MSG->set_flags (ACE_Log_Msg::VERBOSE_LITE);
    ACE_END_TEST;

    return 0;
}