Exemplo n.º 1
0
void sc_memory_shutdown(sc_bool save_state)
{
    sc_events_stop_processing();

    sc_ext_shutdown();

    sc_events_shutdown();
    sc_config_shutdown();

    sc_helper_shutdown();

    sc_storage_shutdown(save_state);

    sc_memory_context_free(s_memory_default_ctx);
    s_memory_default_ctx = 0;

    /// todo: clear contexts
    g_hash_table_destroy(s_context_hash_table);
    s_context_hash_table = 0;
    s_context_id_last = 0;
    g_assert(s_context_id_count == 0);
}
Exemplo n.º 2
0
int main(int argc, char *argv[])
{
    sc_uint item = -1;

    fflush(stdout);
    timer = g_timer_new();
    g_timer_start(timer);

    printf("MD5: %d\n", g_checksum_type_get_length(G_CHECKSUM_MD5) );
    printf("SHA1: %d\n", g_checksum_type_get_length(G_CHECKSUM_SHA1) );
    printf("SHA256: %d\n", g_checksum_type_get_length(G_CHECKSUM_SHA256) );

    sc_storage_initialize("repo");
    g_timer_stop(timer);
    printf("Segment loading speed: %f seg/sec\n", sc_storage_get_segments_count() / g_timer_elapsed(timer, 0));

    //test5();
    //test6();

    //test7();

    while (item != 0)
    {
        printf("Commands:\n"
               "0 - exit\n"
               "1 - test allocation\n"
               "2 - test sc-addr utilities\n"
               "3 - test arc deletion\n"
               "4 - test iterators\n"
               "5 - test contents\n"
               "6 - test content finding\n"
               "7 - test events\n"
               "\nCommand: ");
        scanf("%d", &item);

        printf("\n----- Test %d -----\n", item);

        switch(item)
        {
        case 1:
            test1();
            break;

        case 2:
            test2();
            break;

        case 3:
            test3();
            break;

        case 4:
            test4();
            break;

        case 5:
            test5();
            break;

        case 6:
            test6();
            break;

        case 7:
            test7();
            break;
        };

        printf("\n----- Finished -----\n");
    }

    timer = g_timer_new();
    item = sc_storage_get_segments_count();
    g_timer_reset(timer); // crash when uncomment

    sc_storage_shutdown();
    g_timer_stop(timer);
    printf("Segments save speed: %f seg/sec\n", item / g_timer_elapsed(timer, 0));
    g_timer_destroy(timer);

    return 0;
}