diff options
| author | pengxuanzheng <[email protected]> | 2020-10-09 14:19:37 +0800 |
|---|---|---|
| committer | pengxuanzheng <[email protected]> | 2020-11-02 18:59:51 +0800 |
| commit | 76477b253d9cd3a1f3250965bc25de472c94ad32 (patch) | |
| tree | 20c2f0b107871da324fc9e1a58822207a351fd34 /example | |
| parent | 13da2f2bc68e72b854034e723f93d838e670ca53 (diff) | |
添加upload接口的demo
Diffstat (limited to 'example')
| -rw-r--r-- | example/CMakeLists.txt | 3 | ||||
| -rwxr-xr-x | example/data/test_size.sh | 10 | ||||
| -rw-r--r-- | example/hos_upload_complete.cpp | 12 |
3 files changed, 12 insertions, 13 deletions
diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index c8f32e32..ac09873b 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -1,6 +1,7 @@ cmake_minimum_required(VERSION 3.5) set(CMAKE_BUILD_TYPE Debug) project(hos_write_complete) +project(hos_upload_complete) SET(CMAKE_BUILD_TYPE Debug) link_directories(/usr/local/lib64/) @@ -9,5 +10,7 @@ link_libraries(hos-client-cpp) include_directories(/opt/MESA/include) add_executable(hos_write_complete hos_write_complete.cpp) +add_executable(hos_upload_complete hos_upload_complete.cpp) target_link_libraries(hos_write_complete hos-client-cpp) +target_link_libraries(hos_upload_complete hos-client-cpp) diff --git a/example/data/test_size.sh b/example/data/test_size.sh index 6a3c3cf7..8fbb5533 100755 --- a/example/data/test_size.sh +++ b/example/data/test_size.sh @@ -4,13 +4,15 @@ # Created Time: Mon 21 Sep 2020 04:43:35 PM CST ######################################################################### #!/bin/bash -test_size=("1k" "10k" "100k" "1M" "2M" "3M" "4M") +test_size=("1k" "10k" "100k" "1M" "2M" "3M" "4M" "5M" "10M" "20M" "30M") num=0 -while((${num} < 7)) +while((${num} < 11)) do - echo ./hos_write_complete mybucket ${test_size[$num]}.data 1000 - ./hos_write_complete mybucket ${test_size[$num]}.data 1000 + #echo ./hos_write_complete mybucket ${test_size[$num]}.data 10000 + #./hos_write_complete mybucket ${test_size[$num]}.data 10000 + echo ./hos_upload_complete mybucket ${test_size[$num]}.data 10000 + ./hos_upload_complete mybucket ${test_size[$num]}.data 10000 let "num++" done diff --git a/example/hos_upload_complete.cpp b/example/hos_upload_complete.cpp index f47523bb..84289b13 100644 --- a/example/hos_upload_complete.cpp +++ b/example/hos_upload_complete.cpp @@ -106,13 +106,12 @@ int main(int argc, char *argv[]) } debuginfo("hos_verify_bucket success ... \n"); -#if 0 - fd = hos_open_fd(handle, bucket, object, callback, (void *)&data, 0, mode); +#if 1 debuginfo("hos_upload_file start ...\n"); clock_gettime(CLOCK_MONOTONIC, &start); for (i = 0; i < test_times; i++) { - hos_write(fd, object, 0, 0); + hos_upload_file(handle, bucket, object, callback, (void *)&data, 0); } clock_gettime(CLOCK_MONOTONIC, &end); time = calc_time(start, end); @@ -121,16 +120,11 @@ int main(int argc, char *argv[]) debuginfo("hos_upload_file end ...\n"); #else - mode = BUFF_MODE; - for (i = 0; i < 10000; i++) - { - fd[i] = hos_open_fd(handle, bucket, object, callback, (void *)&data, 0, mode); - } debuginfo("hos_upload_buf start ...\n"); clock_gettime(CLOCK_MONOTONIC, &start); for (i = 0; i < test_times; i++) { - hos_write(fd[i], buf, buf_size, 0); + hos_upload_buf(handle, bucket, object, buf, buf_len, callback, (void *)&data, 0); } clock_gettime(CLOCK_MONOTONIC, &end); time = calc_time(start, end); |
