diff options
Diffstat (limited to 'example/performance')
| -rw-r--r-- | example/performance/HosClientPerformance.cpp | 35 | ||||
| -rwxr-xr-x | example/performance/test.sh | 8 |
2 files changed, 25 insertions, 18 deletions
diff --git a/example/performance/HosClientPerformance.cpp b/example/performance/HosClientPerformance.cpp index 8c115cd0..ac2a6175 100644 --- a/example/performance/HosClientPerformance.cpp +++ b/example/performance/HosClientPerformance.cpp @@ -69,8 +69,7 @@ typedef struct userdata_s static size_t calc_time(struct timespec start, struct timespec end) { - return (end.tv_sec * 1000 * 1000 * 1000 + end.tv_nsec - - (start.tv_sec * 1000 * 1000 * 1000 + start.tv_nsec)); + return (end.tv_sec - start.tv_sec) * 1000 * 1000 * 1000 + end.tv_nsec - start.tv_nsec; } int read_file_list(const char *path, char file_name[][256]) @@ -216,7 +215,7 @@ static int upload_buff(char * buff, int buff_len, int test_times, thread_info_t { int i = 0; int j = 0; - size_t fd = 0; + size_t fd[1000] = {0}; size_t tmp = 0; size_t rest = 0; struct timespec tstart, ttmp; @@ -230,11 +229,11 @@ static int upload_buff(char * buff, int buff_len, int test_times, thread_info_t int drop = 0; double variance = 0.00; double average = 0.00; - long record[1000] = {0}; + long record[30000] = {0}; if (conf->slice) { - fd = hos_open_fd(thread_info->handle, conf->bucket, conf->object, callback, NULL, thread_info->thread_num, conf->mode); + fd[0] = hos_open_fd(thread_info->handle, conf->bucket, conf->object, callback, NULL, thread_info->thread_num, conf->mode); for (i = 0; i < test_times; i++) { j = 0; @@ -245,10 +244,10 @@ static int upload_buff(char * buff, int buff_len, int test_times, thread_info_t rest = buff_len - tmp; if (rest < conf->slice) { - hos_write(fd, &buff[tmp], rest, thread_info->thread_num); + hos_write(fd[0], &buff[tmp], rest, thread_info->thread_num); break; } - hos_write(fd, &buff[tmp], conf->slice, thread_info->thread_num); + hos_write(fd[0], &buff[tmp], conf->slice, thread_info->thread_num); j++; } clock_gettime(CLOCK_MONOTONIC, &ttmp); @@ -272,7 +271,7 @@ static int upload_buff(char * buff, int buff_len, int test_times, thread_info_t if (conf->mode & APPEND_MODE) { - fd = hos_open_fd(thread_info->handle, conf->bucket, conf->object, callback, NULL, thread_info->thread_num, conf->mode); + fd[0] = hos_open_fd(thread_info->handle, conf->bucket, conf->object, callback, NULL, thread_info->thread_num, conf->mode); #if 1 for (i = 0; i < test_times; i++) { @@ -285,10 +284,10 @@ static int upload_buff(char * buff, int buff_len, int test_times, thread_info_t rest = buff_len - tmp; if (rest < conf->append_size) { - hos_write(fd, &buff[tmp], rest, thread_info->thread_num); + hos_write(fd[0], &buff[tmp], rest, thread_info->thread_num); break; } - hos_write(fd, &buff[tmp], conf->append_size, thread_info->thread_num); + hos_write(fd[0], &buff[tmp], conf->append_size, thread_info->thread_num); j++; } #if 1 @@ -315,14 +314,14 @@ static int upload_buff(char * buff, int buff_len, int test_times, thread_info_t for (i = 0; i < test_times; i++) { clock_gettime(CLOCK_MONOTONIC, &tstart); - fd = hos_open_fd(thread_info->handle, conf->bucket, conf->object, callback, NULL, thread_info->thread_num, conf->mode); - ret = hos_write(fd, buff, buff_len, thread_info->thread_num); + fd[i] = hos_open_fd(thread_info->handle, conf->bucket, conf->object, callback, NULL, thread_info->thread_num, conf->mode); + ret = hos_write(fd[i], buff, buff_len, thread_info->thread_num); if (ret == HOS_CLIENT_OK) { success_cnt++; }else { - printf("error code:%d, thread_id:%d\n", ret, thread_info->thread_num); + //printf("error code:%d, thread_id:%d\n", ret, thread_info->thread_num); //break; } clock_gettime(CLOCK_MONOTONIC, &ttmp); @@ -348,7 +347,13 @@ static int upload_buff(char * buff, int buff_len, int test_times, thread_info_t } } - hos_close_fd(fd, thread_info->thread_num); + for (i = 0; i < test_times; i++) + { + if (fd[i] > 2) + { + hos_close_fd(fd[i], thread_info->thread_num); + } + } return 0; } @@ -365,7 +370,7 @@ static void *put_object_thread(void *ptr) char *buff = NULL; char file_name[100][256]; struct stat s_buf; - int test_times = 100; + int test_times = 1000; buff = (char *)malloc(30 * 1024 * 1024); if (buff == NULL) diff --git a/example/performance/test.sh b/example/performance/test.sh index 19a04113..16948150 100755 --- a/example/performance/test.sh +++ b/example/performance/test.sh @@ -10,7 +10,7 @@ size=(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 num=0 -while((${num} < 37)) +while((${num} < 100)) do #./HosClientPerformance -a ${size[$num]} #echo "./HosClientPerformance -a ${size[$num]} -A -f ./file/100k.data" @@ -19,7 +19,9 @@ do #./HosClientPerformance -f ./file/${size[$num]}.data -F #echo ./HosClientPerformance -a 100 -A -f ./file/100k.data -t ${size[$num]} -S 1024 #./HosClientPerformance -a 100 -A -f ./file/100k.data -t ${size[$num]} -S 1024 - echo ./HosClientPerformance -a 100 -A -f ./file/100k.data -S ${size[$num]} -t 32 - ./HosClientPerformance -a 100 -A -f ./file/100k.data -S ${size[$num]} -t 32 + #echo ./HosClientPerformance -a 100 -A -f ./file/100k.data -S ${size[$num]} -t 32 + #./HosClientPerformance -a 100 -A -f ./file/100k.data -S ${size[$num]} -t 32 + echo ./HosClientPerformance -P1 -t32 + ./HosClientPerformance -P1 -t32 let "num++" done |
