33bubble 发表于 2014-04-07 15:08

请问楼主是如何实现记录文件的上传与下载时间的?我最近在写一个相关的作业,焦急的期待中。。。

33bubble 发表于 2014-04-07 15:13

请问楼主如何得到文件的上传与下载的时间,最近在做一个相关的事情,在线等。。。谢啦!

workyixin 发表于 2014-04-10 04:58

回复 12# 33bubble


    上传时间:很简单,客户端java程序批量上传:开始前记录一个当前时间,然后等上传完10万大图和10万小图之后,再得到当前时间,相减得到两者间隔(101分钟)。
    下载时间:这是请测试人员使用loadrunner压力测试得到的,50并发循环访问dfs中存储的图片,loadrunner会计算出平均的响应时间。

33bubble 发表于 2014-04-14 20:24

非常感谢楼主。可是我是初次接触FastDFS,没有深入了解,我近几天一直有个的想法是直接在FastDFS下的client目录下直接在fdfs_download_file.c中添加gettimeofday(&start,NULL)和gettimeofday(&end,NULL),然后两者相减得到的结果printf出来,但是在执行完程序后,无法显示结果,请您帮我分析一下,麻烦了!

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <string.h>

#include <sys/time.h>#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "fdfs_client.h"
#include "logger.h"
#define MILLION 1000000L
int main(int argc, char *argv[])
{
        char *conf_filename;
        char *local_filename;

        TrackerServerInfo *pTrackerServer;
        int result;
        char file_id;

        int64_t file_size;

       long timedif;
      struct timeval tpend,tpstart;
       gettimeofday(&tpstart,NULL);         if (argc < 3)
        {
                printf("Usage: %s <config_file> <remote file id> " \
                        "\n", argv);
                return 1;
        }

        log_init();
        g_log_context.log_level = LOG_ERR;

        conf_filename = argv;
        if ((result=fdfs_client_init(conf_filename)) != 0)
        {
                return result;
        }

        pTrackerServer = tracker_get_connection();
        if (pTrackerServer == NULL)
        {
                fdfs_client_destroy();
                return errno != 0 ? errno : ECONNREFUSED;
        }

        snprintf(file_id, sizeof(file_id), "%s", argv);

        if (argc >= 4)
        {
                local_filename = argv;
        }
        else
        {
                local_filename = strrchr(file_id, '/');
                if (local_filename != NULL)
                {
                        local_filename++;//skip /
                }
                else
                {
                        local_filename = file_id;
                }
        }

        result = storage_download_file_to_file1( \
                        pTrackerServer, NULL, \

                     file_id,local_filename,&file_size);
gettimeofday(&tpend,NULL);
      timedif=MILLION*(tpend.tv_sec-tpstart.tv_sec)+tpend.tv_usec-tpstart.tv_usec;

       printf("the time is %ld second",timedif);
;        if (result != 0)
        {
                printf("download file fail, " \
                        "error no: %d, error info: %s\n", \
                        result, STRERROR(result));
        }


        fdfs_quit(pTrackerServer);
        tracker_close_all_connections();
        fdfs_client_destroy();

        return 0;
}

之后步骤是:执行make,make install后,对文件进行下载。
可是时间无法显示出来。

33bubble 发表于 2014-04-14 20:26

希望楼主不要嫌我烦,我只是想弄明白

workyixin 发表于 2014-04-15 06:31

回复 15# 33bubble

不好意思啊,不熟悉C语言,我用的是java客户端。你请别人帮忙看下吧。
貌似思路没问题,你再设法调试和编译吧。
另外不如自己编新的程序来调用源程序,这样自己可以循环多次调用上传or下载功能,自动计算时间平均值,打印输出。
   

33bubble 发表于 2014-04-15 07:49

谢谢您了!

john_04047210 发表于 2014-05-04 11:07

调用它的日志函数,程序里肯定做了重定向了,调试信息我一般都是通过日志来输出的回复 14# 33bubble


   

gg9654 发表于 2014-08-04 13:43

mark 持续关注

好人大叔 发表于 2014-12-09 17:12

java客户端每上传一次都要close到trace的连接是吧?
也就是这个是短连接啦?
页: 1 [2] 3
查看完整版本: 4个关于fastDFS的大数据量下性能的问题