zoukankan      html  css  js  c++  java
  • 事务信息获取函数

    事务信息获取函数

    • double lr_get_transaction_think_time(const char * transaction_name)

      用于返回指定的运行事务当前所消耗的思考时间

    double think_time;
    
    lr_start_transaction(“Flight”);
    
    web_url(“home; sz = 234x60; tile = 1; ord = 977672495775323400”,
    
            “URL = http://ad.doubleclick.net/...ord=977672495775323400”,
    
            ... ..
    
            “Mode = URL”,
    
            LAST);
    
    think_time = lr_get_transaction_think_time(“Flight”);
    
    status = web_submit_data(“flight”,
    
            “Action = http://www.mercury-tours.com/cgi-bin/tours?ITN_RESPONSE +”,
    
            “Method = POST”,
    
            “TargetFrame =”,
    
            ... ...
    
            LAST);
    
     
    
    / *结束事务与操作结果 - 通过或失败* /
    
    if(status == 0)
    
        lr_end_transaction(“Flight”,LR_PASS);
    
            else
    
        lr_end_transaction(“Flight”,LR_FAIL);
    
    if(think_time)
    
        lr_output_message(“事务认为时间是%f秒”,think_time);
    
    else
    
    lr_output_message(“思考时间无法确定”);
    • double lr_get_transaction_wasted_time(const char * transaction)

    获得对应事务到达该函数运行位置时的wasted时间 

    函数统计的是事物开始到此函数位置,lr自身的浪费时间(如:执行关联、检查点等函数的时间)。 

    损耗时间通常是指脚本消耗在为了支持测试分析而做的操作时间。这些操作不会被实际用户所执行。 
    例如一些循环赋值操作或插入检查点操作。消耗的时间有lr_wasted_time函数在 
    lr_get_transaction_wasted_time函数之前移除了,移除后才得到对应的结果。 
    函数必须注意, 
    一它只能对当前运行状态的事物才能返回大于等于0的结果,否则返回小于0的结果。 
    二是他使用之前应调用lr_wansted_time 函数移除过损耗时间 wasted time,否则lr_get_transaction_wansted_time将返回0。

    • double lr_get_transaction_duration(const char * transaction)
    • 用于获取事务所消耗的时间。

      

    Action2()
    
    {
    
        double duration  = 0;
    
        double wastedtime = 0;
    
     
    
        lr_start_transaction("login");
    
        //打开登录界面
    
        web_url("WebTours",
    
            "URL=http://127.0.0.1:1080/WebTours/",
    
            "Resource=0",
    
            "RecContentType=text/html",
    
            "Referer=",
    
            "Snapshot=t16.inf",
    
            "Mode=HTML",
    
            LAST);
    
     
    
        lr_think_time(4);
    
     
    
        //事务达到该函数运行位置时持续的时间
    
        duration = lr_get_transaction_duration("login");
    
        lr_output_message("duration %f", duration);
    
     
    
        //事务达到该函数运行位置时浪费的时间
    
        wastedtime = lr_get_transaction_wasted_time("login");
    
        lr_output_message("wastedtime %f", wastedtime);
    
     
    
        //为事务添加一个浪费时间 5s//该浪费时间无法直接通过lr_get_transaction_wasted_time获得
    
        lr_wasted_time(5);
    
        wastedtime = lr_get_transaction_wasted_time("login");
    
      lr_output_message("wastedtime %f", wastedtime);
    
     
    
        //暂停事务
    
        lr_stop_transaction("login");
    
     
    
        //注意函数的位置
    
        web_reg_find("Search=Body", "SaveCount=login_times", "Text=jojo", LAST);
    
     
    
        //提交登录页面的表单
    
        web_submit_form("login.pl",
    
            "Snapshot=t17.inf",
    
            ITEMDATA,
    
            "Name=username", "Value=jojo", ENDITEM,
    
            "Name=password", "Value=bean", ENDITEM,
    
            "Name=login.x", "Value=0", ENDITEM,
    
            "Name=login.y", "Value=0", ENDITEM,
    
            LAST);
    
     
    
        lr_think_time(4);
    
     
    
        //事务达到该函数运行位置时浪费的时间
    
        wastedtime = lr_get_transaction_wasted_time("login");
    
        lr_output_message("wastedtime %f", wastedtime);
    
     
    
        if(atoi(lr_eval_string("{login_times}")) >= 1)
    
            lr_end_transaction("login", LR_PASS);
    
        else
    
            lr_end_transaction("login", LR_FAIL);
    
      
    
        return 0;
    
    }
    C 语言:
    
    double lr_get_transaction_duration(const char *transaction);
    
       
    Example:
    
    Action()
    
    {
    
          double Connect_trans_time;  // 接收函数返回值
    
          double Move_trans_time;
    
       
    
          lr_start_transaction("Connect_trans");
    
          lr_create_socket("socket0","TCP","RemoteHost = localhost:1111",LrsLastArg);  // IP和端口仅供参考
    
          //......(others)
    
       
    
          // 调用 lr_get_transaction_duration() 函数
    
          Connect_trans_time = lr_get_transaction_duration("Connect_trans");
    
          lr_end_transaction("Connect_trans",LR_AUTO);
    
       
    
          lr_start_transaction("Move_trans");
    
          //......(others)
    
          Move_trans_time = lr_get_transaction_duration("Move"); // 获取 Move_trans 事件执行到此处所用时间
    
          lr_end_transaction("Move_trans",LR_AUTO);
    
       
    
          lr_output_message("The duration up to the <Connect_trans_time> is %f seconds",Connect_trans_time);
    
          lr_output_message("The duration up to the <Move_trans_time> is %f seconds",Move_trans_time);
    
       
    
          return 0;
    
    }
    
        
    
       
    
    Action.c(1259): Notify: Transaction "Connect_trans" ended with "Pass" status (Duration:1.1164)
    
    Action.c(1717): Notify: Transaction "Move_trans" ended with "Pass" status (Duration: 0.4036)
    
    Action.c(1719): The duration up to the <Connec_trans_time> is 1.116110 seconds
    
    Action.c(1721): The duration up to the <Move_trans_time> is 0.403350 seconds
    
        
    
    根据业务操作分离出脚本中的两个事件,Connect(连接DB)操作和Move(拖屏)操作,Contro中运行结果显示“拖屏”消耗时间远大于“连接”消耗时间,这同程序设计与实现的实际情况不符。
    
    所以调用了【lr_get_transaction_duration();】函数来验证事件的运行时间,进一步分析性能问题原因所在。
    
    验证结果已证明拖屏操作消耗时间的确小于连接操作消耗时间。
    • int lr_get_transaction_status(const char * transaction_name)

      用于获取事务的状态。 须要注意的是,一个事务如果以lr-end_transaction结束后,再用lr_get_transaction_status获取对应事务状态时将会发生错误。因此这个函数仅能返回处于运行中事务的状态,不能返回事务以什么状态结束(即最后的状态)。

    • void lr_wasted_time(long wasteTime)

      因为事务中总是有消耗的时间,可能因为函数运行,或者事务运行而产生的时间,跟响应时间有些不符,可加入lr_wasted_time,事务自动扣除该浪费时间

  • 相关阅读:
    形象理解ERP(转)
    禁用windows server 2008 域密码复杂性要求策略
    How to adding find,filter,remove filter on display method Form
    Windows Server 2008 R2激活工具
    How to using bat command running VS development SSRS report
    Creating Your First Mac AppGetting Started
    Creating Your First Mac AppAdding a Track Object 添加一个 Track 对象
    Creating Your First Mac AppImplementing Action Methods 实现动作方法
    Creating Your First Mac AppReviewing the Code 审查代码
    Creating Your First Mac AppConfiguring the window 设置窗口
  • 原文地址:https://www.cnblogs.com/lvchengda/p/12625026.html
Copyright © 2011-2022 走看看