オープンソース・ソフトウェアの開発とダウンロード

Subversion リポジトリの参照

Contents of /memsetc-bench.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5 - (show annotations) (download) (as text)
Wed Jul 14 15:24:20 2010 UTC (13 years, 10 months ago) by tullio
File MIME type: text/x-csrc
File size: 1404 byte(s)
pool version and added benchmark program for FreeBSD

1 #include <libmemcached/memcached.h>
2 #include <stdio.h>
3 #include <string.h>
4 #include <stdlib.h>
5 #include <time.h>
6 #include <sys/types.h>
7 #include <md5.h>
8 #include <omp.h>
9
10 int main(int argc, char *argv[])
11 {
12 srand(time(NULL));
13 int i, ctx;
14 int suc = 0;
15 memcached_st *memc;
16 memcached_return rc;
17 memcached_server_st *servers;
18 memc= memcached_create(NULL);
19 servers= memcached_servers_parse(argv[1]);
20 memcached_server_push(memc, servers);
21 memcached_server_list_free(servers);
22 rc = memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, 1);
23 #pragma omp parallel for
24 for(i=0;i<10000;++i)
25 {
26 MD5_CTX con;
27 char key[33], val[11];
28 int randkey;
29 randkey = rand_r(&ctx);
30 sprintf(key,"%010d",randkey);
31 sprintf(val,"%010d",randkey);
32 MD5Init(&con);
33 MD5Update(&con, key, strlen(key));
34 MD5End(&con, key);
35 /* printf("%s:%s\n",key,val); */
36 rc= memcached_set(memc,key, strlen(key),
37 val, strlen(val), 0, 0);
38 if (rc != MEMCACHED_SUCCESS)
39 {
40 fprintf(stderr, "memset: %s: memcache error %s",
41 key, memcached_strerror(memc, rc));
42 if (memc->cached_errno)
43 fprintf(stderr, " system error %s", strerror(memc->cached_errno));
44 fprintf(stderr, "\n");
45 }else
46 {
47 ++suc;
48 }
49 }
50 memcached_free(memc);
51 printf("try=%d success=%d ratio=%f\n",i,suc,(double)suc/i*100.0);
52 return(0);
53 }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26