Exemplo n.º 1
0
int main() {
    perf_test(1, 100000, 1);
    perf_test(5, 100000, 5);
    perf_test(10, 100000, 10);
    perf_test(20, 100000, 20);
    return 0;
}
Exemplo n.º 2
0
int
test_memcpy_perf(void)
{
	int ret;

	ret = perf_test();
	if (ret != 0)
		return -1;
	return 0;
}
Exemplo n.º 3
0
int main()
{	
	//struct kmem_cache *foo_cache =kmem_cache_create("foo",1500, 0, NULL, NULL);

	//struct foo *fp = kmem_cache_alloc(foo_cache,0);

 	//alloc_and_free();
	perf_test();

	//printf("main end %d\n", __slab_sz(2000));

	return 0;
}
Exemplo n.º 4
0
static int
test_distributor_perf(void)
{
	static struct rte_distributor *d;
	static struct rte_mempool *p;

	if (rte_lcore_count() < 2) {
		printf("ERROR: not enough cores to test distributor\n");
		return -1;
	}

	/* first time how long it takes to round-trip a cache line */
	time_cache_line_switch();

	if (d == NULL) {
		d = rte_distributor_create("Test_perf", rte_socket_id(),
				rte_lcore_count() - 1);
		if (d == NULL) {
			printf("Error creating distributor\n");
			return -1;
		}
	} else {
		rte_distributor_flush(d);
		rte_distributor_clear_returns(d);
	}

	const unsigned nb_bufs = (511 * rte_lcore_count()) < BIG_BATCH ?
			(BIG_BATCH * 2) - 1 : (511 * rte_lcore_count());
	if (p == NULL) {
		p = rte_mempool_create("DPT_MBUF_POOL", nb_bufs,
				MBUF_SIZE, BURST,
				sizeof(struct rte_pktmbuf_pool_private),
				rte_pktmbuf_pool_init, NULL,
				rte_pktmbuf_init, NULL,
				rte_socket_id(), 0);
		if (p == NULL) {
			printf("Error creating mempool\n");
			return -1;
		}
	}

	rte_eal_mp_remote_launch(handle_work, d, SKIP_MASTER);
	if (perf_test(d, p) < 0)
		return -1;
	quit_workers(d, p);

	return 0;
}
Exemplo n.º 5
0
int ssl_sock_test(void)
{
    int ret;

    PJ_LOG(3,("", "..get cipher list test"));
    ret = get_cipher_list();
    if (ret != 0)
	return ret;

    PJ_LOG(3,("", "..https client test"));
    ret = https_client_test(30000);
    // Ignore test result as internet connection may not be available.
    //if (ret != 0)
	//return ret;

#ifndef PJ_SYMBIAN
   
    /* On Symbian platforms, SSL socket is implemented using CSecureSocket, 
     * and it hasn't supported server mode, so exclude the following tests,
     * which require SSL server, for now.
     */

    PJ_LOG(3,("", "..echo test w/ TLSv1 and PJ_TLS_RSA_WITH_DES_CBC_SHA cipher"));
    ret = echo_test(PJ_SSL_SOCK_PROTO_TLS1, PJ_SSL_SOCK_PROTO_TLS1, 
		    PJ_TLS_RSA_WITH_DES_CBC_SHA, PJ_TLS_RSA_WITH_DES_CBC_SHA, 
		    PJ_FALSE, PJ_FALSE);
    if (ret != 0)
	return ret;

    PJ_LOG(3,("", "..echo test w/ SSLv23 and PJ_TLS_RSA_WITH_AES_256_CBC_SHA cipher"));
    ret = echo_test(PJ_SSL_SOCK_PROTO_SSL23, PJ_SSL_SOCK_PROTO_SSL23, 
		    PJ_TLS_RSA_WITH_AES_256_CBC_SHA, PJ_TLS_RSA_WITH_AES_256_CBC_SHA,
		    PJ_FALSE, PJ_FALSE);
    if (ret != 0)
	return ret;

    PJ_LOG(3,("", "..echo test w/ incompatible proto"));
    ret = echo_test(PJ_SSL_SOCK_PROTO_TLS1, PJ_SSL_SOCK_PROTO_SSL3, 
		    PJ_TLS_RSA_WITH_DES_CBC_SHA, PJ_TLS_RSA_WITH_DES_CBC_SHA,
		    PJ_FALSE, PJ_FALSE);
    if (ret == 0)
	return PJ_EBUG;

    PJ_LOG(3,("", "..echo test w/ incompatible ciphers"));
    ret = echo_test(PJ_SSL_SOCK_PROTO_DEFAULT, PJ_SSL_SOCK_PROTO_DEFAULT, 
		    PJ_TLS_RSA_WITH_DES_CBC_SHA, PJ_TLS_RSA_WITH_AES_256_CBC_SHA,
		    PJ_FALSE, PJ_FALSE);
    if (ret == 0)
	return PJ_EBUG;

    PJ_LOG(3,("", "..echo test w/ client cert required but not provided"));
    ret = echo_test(PJ_SSL_SOCK_PROTO_DEFAULT, PJ_SSL_SOCK_PROTO_DEFAULT, 
		    PJ_TLS_RSA_WITH_AES_256_CBC_SHA, PJ_TLS_RSA_WITH_AES_256_CBC_SHA,
		    PJ_TRUE, PJ_FALSE);
    if (ret == 0)
	return PJ_EBUG;

    PJ_LOG(3,("", "..echo test w/ client cert required and provided"));
    ret = echo_test(PJ_SSL_SOCK_PROTO_DEFAULT, PJ_SSL_SOCK_PROTO_DEFAULT, 
		    PJ_TLS_RSA_WITH_AES_256_CBC_SHA, PJ_TLS_RSA_WITH_AES_256_CBC_SHA,
		    PJ_TRUE, PJ_TRUE);
    if (ret != 0)
	return ret;

    PJ_LOG(3,("", "..performance test"));
    ret = perf_test(PJ_IOQUEUE_MAX_HANDLES/2 - 1, 0);
    if (ret != 0)
	return ret;

    PJ_LOG(3,("", "..client non-SSL (handshake timeout 5 secs)"));
    ret = client_non_ssl(5000);
    /* PJ_TIMEDOUT won't be returned as accepted socket is deleted silently */
    if (ret != 0)
	return ret;

#endif

    PJ_LOG(3,("", "..server non-SSL (handshake timeout 5 secs)"));
    ret = server_non_ssl(5000);
    if (ret != PJ_ETIMEDOUT)
	return ret;

    return 0;
}
Exemplo n.º 6
0
static int
test_distributor_perf(void)
{
	static struct rte_distributor *ds;
	static struct rte_distributor *db;
	static struct rte_mempool *p;

	if (rte_lcore_count() < 2) {
		printf("ERROR: not enough cores to test distributor\n");
		return -1;
	}

	/* first time how long it takes to round-trip a cache line */
	time_cache_line_switch();

	if (ds == NULL) {
		ds = rte_distributor_create("Test_perf", rte_socket_id(),
				rte_lcore_count() - 1,
				RTE_DIST_ALG_SINGLE);
		if (ds == NULL) {
			printf("Error creating distributor\n");
			return -1;
		}
	} else {
		rte_distributor_clear_returns(ds);
	}

	if (db == NULL) {
		db = rte_distributor_create("Test_burst", rte_socket_id(),
				rte_lcore_count() - 1,
				RTE_DIST_ALG_BURST);
		if (db == NULL) {
			printf("Error creating burst distributor\n");
			return -1;
		}
	} else {
		rte_distributor_clear_returns(db);
	}

	const unsigned nb_bufs = (511 * rte_lcore_count()) < BIG_BATCH ?
			(BIG_BATCH * 2) - 1 : (511 * rte_lcore_count());
	if (p == NULL) {
		p = rte_pktmbuf_pool_create("DPT_MBUF_POOL", nb_bufs, BURST,
			0, RTE_MBUF_DEFAULT_BUF_SIZE, rte_socket_id());
		if (p == NULL) {
			printf("Error creating mempool\n");
			return -1;
		}
	}

	printf("=== Performance test of distributor (single mode) ===\n");
	rte_eal_mp_remote_launch(handle_work, ds, SKIP_MASTER);
	if (perf_test(ds, p) < 0)
		return -1;
	quit_workers(ds, p);

	printf("=== Performance test of distributor (burst mode) ===\n");
	rte_eal_mp_remote_launch(handle_work, db, SKIP_MASTER);
	if (perf_test(db, p) < 0)
		return -1;
	quit_workers(db, p);

	return 0;
}
int main(int argc, char* argv[]) {

    int rc = 0;
    int rv = 0;

    // ans variables
    ans_client_t *  ans_client = NULL;
    ans_open_t      ans_input;

    PxdTest::InfraHelper infraHelper(username, password, "pxd_test_server");

    // pxd variables
    pxd_error_t err;
    pxd_open_t open;
    pxd_id_t id;
    pxd_cred_t cred;

    u64 user_id = 0;
    u64 device_id = 0;
    char inst_id[] = "0";
    char region[] = "US";

    string pxdLoginBlob = "";
    string pxdSessionKey = "";
    string ansLoginBlob = "";
    string ansSessionKey = "";

    if(parse_args(argc, argv) != 0) {
        goto exit;
    }

    VPL_SET_UNINITIALIZED(&(test_context.sem));
    if((rc = VPLSem_Init(&(test_context.sem), 1, 0)) != VPL_OK) {
        LOG_ERROR("Failed to create semaphore.");
        rv = rc;
        goto exit;
    }

    test_context.result = -1;

    // Init
    VPL_Init();

    // connect to infra
    rc = infraHelper.ConnectInfra(user_id, device_id);
    if (rc != 0) {
        LOG_ERROR("ConnectInfra failed: %d", rc);
        rv = rc;
        goto exit;
    }

    // ANS init
    // get ans blob and session key
    infraHelper.GetAnsLoginBlob(ansSessionKey, ansLoginBlob);

    ans_input.clusterName   = ans_name.c_str();
    ans_input.deviceType    = "default";
    ans_input.application   = inst_id;
    ans_input.verbose       = true;
    ans_input.callbacks     = &ans_callbacks;

    ans_input.blob = (void*)ansLoginBlob.data();
    ans_input.blobLength  = static_cast<int>(ansLoginBlob.size());
    ans_input.key  = (void*)ansSessionKey.data();
    ans_input.keyLength   = static_cast<int>(ansSessionKey.size());

    ans_client = ans_open(&ans_input);

    // wait for login done
    LOG_INFO("Wait for ANS login done");
    {
        int retry = 15;
        while (!ans_login_done) {
            VPLThread_Sleep(VPLTime_FromSec(1));
            if (retry-- < 0) {
                goto exit;
            }
        }
    }
    LOG_INFO("ANS login done");

    // PDX init
    // get pxd blob and session key
    rc = infraHelper.GetPxdLoginBlob(inst_id, ansLoginBlob, pxdSessionKey, pxdLoginBlob);
    if(rc != 0) {
        LOG_ERROR("getPxdLoginBlob failed: %d", rc);
        rv = rc;
        goto exit;
    }

    hex_dump("pxdSessionKey - ", pxdSessionKey.data(), pxdSessionKey.size());
    hex_dump("pxdLoginBlob - ", pxdLoginBlob.data(), pxdLoginBlob.size());

    rc = infraHelper.GetCCDServerKey(inst_id, ccdServerKey);
    if(rc != 0) {
        LOG_ERROR("getCCDServerKey failed: %d", rc);
        rv = rc;
        goto exit;
    }
    hex_dump("ccdServerKey - ", ccdServerKey.data(), ccdServerKey.size());

    // pxd_open

    LOG_INFO("ID is "FMTu64" Device id "FMTu64" Inst id %s",
              user_id, device_id, inst_id);
    // TODO ask JonB to change type
    memset(&open, 0, sizeof(open));
    open.cluster_name = (char*)pxd_name.c_str();
    open.is_incoming = true;
    open.opaque = &test_context;

    open.credentials = &cred;
    open.credentials->id = &id;
    open.credentials->id->device_id = device_id;
    open.credentials->id->user_id = user_id;
    open.credentials->id->instance_id = inst_id;
    open.credentials->id->region = region;
    // TODO ask JonB to change type
    open.credentials->key = (void*)pxdSessionKey.data();
    open.credentials->key_length  = static_cast<int>(pxdSessionKey.size());
    // TODO ask JonB to change type
    open.credentials->opaque = (void*)pxdLoginBlob.data();
    open.credentials->opaque_length = static_cast<int>(pxdLoginBlob.size());

    open.callback = &pxd_callbacks;

    pxd_client = pxd_open(&open, &err);
    if(pxd_client == NULL) {
        LOG_ERROR("pxd_open failed");
        goto exit;
    }

    // Wait for client connected
    LOG_INFO("Please connect the client to server.");
    VPLSem_TimedWait(&(test_context.sem), VPLTime_FromSec(100));
    if(test_context.result != 0 && test_context.result != pxd_op_successful) {
        LOG_ERROR("client connected failed");
        goto exit;
    }
    LOG_INFO("Client connected.");
    {
        int yes = 1;
        int rt = VPLSocket_SetSockOpt( test_context.socket, VPLSOCKET_IPPROTO_TCP, VPLSOCKET_TCP_NODELAY, (void*)&yes, sizeof(yes) );
        ASSERT(rt == 0);
    }
    perf_test(test_context.socket, block_size, bs_count);

exit:
    if(rv != 0) {
        LOG_ERROR("Main failed %d", rv);
    } else {
        LOG_INFO("Main exit");
    }

    if(pxd_client != NULL) {
        pxd_close(&pxd_client, 1, &err);
    }

    VPLSem_Destroy(&(test_context.sem));
    return 0;
}
Exemplo n.º 8
0
int main() {
    sqlite3 *db;
    char *zErrMsg = 0;
    int  rc;
    char buf[4096] = {0};

    /* Open database */
    rc = sqlite3_open("test.db", &db);
    if( rc ) {
        fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
        exit(1);
    } else {
        fprintf(stdout, "Opened database successfully\n");
    }

    sqlite3_enable_load_extension(db, 1);

    rc = sqlite3_load_extension(db, "../src/libredis_vtbl.so", 0, &zErrMsg);
    if( rc ) {
        fprintf(stderr, "Can't load module: %s\n", zErrMsg);
        exit(1);
    } else {
        fprintf(stdout, "Loaded module successfully\n");
    }

    exec(db, "PRAGMA synchronous = OFF");

    /* test0 - sqlite table */
    snprintf(buf, sizeof(buf), 
        "CREATE TABLE IF NOT EXISTS test0 (\n"
        "   blah          VARCHAR(255),\n"
        "   blah2          INTEGER,\n"
        "   blah3     VARCHAR(6)\n"
        ");\n");
    if(exec(db, buf)) goto error;

    /* test1 - sqlite redis backed table */
    snprintf(buf, sizeof(buf), 
        "CREATE VIRTUAL TABLE test1 USING redis (localhost:6379, prefix,\n"
        "   blah          VARCHAR(255),\n"
        "   blah2          INTEGER,\n"
        "   blah3     VARCHAR(6)\n"
        ");\n");
    if(exec(db, buf)) goto error;

    exec(db, "select redis_create_index(blah) from test1");

    snprintf(buf, sizeof(buf), 
        "insert into test0 "
        "(blah, blah2, blah3) "
        "values ('%s','%d', '%s')", 
        "42ea2b19af3a4678b1b71a335cf5a9ce", 1377670786, "1008");
    if(exec(db, buf)) goto error;

    snprintf(buf, sizeof(buf), 
        "insert into test1 "
        "(blah, blah2, blah3) "
        "values ('%s','%d', '%s')", 
        "42ea2b19af3a4678b1b71a335cf5a9ce", 1377670786, "1008");
    if(exec(db, buf)) goto error;

    exec(db, "select * from test0");
    exec(db, "select * from test1");

    exec(db, "DELETE from test0");
    exec(db, "DELETE from test1");


    if(perf_test(db, 0)) goto error;
    if(perf_test(db, 1)) goto error;

// cleanup
    exec(db, "DROP TABLE test0");
    exec(db, "DROP TABLE test1");
    sqlite3_close(db);
    sqlite3_shutdown();
    return 0;
error:
    exec(db, "DROP TABLE test0");
    exec(db, "DROP TABLE test1");
    sqlite3_close(db);
    sqlite3_shutdown();
    return 1;
}