博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
为LoadRunner写一个lr_save_float函数
阅读量:4199 次
发布时间:2019-05-26

本文共 1127 字,大约阅读时间需要 3 分钟。

LoadRunner中有lr_save_int() 和lr_save_string() 函数,但是没有保存浮点数到变量的lr_save_float函数。《》这篇文章介绍了如何写一个这样的函数:

 

 

 

 

void lr_save_float(const float value, const char *param, const int decimals)

// ----------------------------------------------------------------------------
// Saves a float into a lr variable, much like lr_save_int() saves an integer
//
// Parameters:
//   value       Float value to store
//   param       Loadrunner variable name
//   decimals    Number of decimals in the result string
//
// Returns:
//   N/A
//
// Example:
//   lr_save_float(123.456, "myVar", 2);  // myVar = 123.46 (includes rounding)
//
// ----------------------------------------------------------------------------
{
  char buf[64];                              // if more>63 digits -> your problem <IMG class=wp-smiley alt=:) src="">
  char formatbuf[16];                        // 16 chars should be adequate

  sprintf( formatbuf, "%%.%df", decimals);   // Build the "%?.f" format string

  sprintf( buf, formatbuf, value);           // sprintf the value
  lr_save_string( buf, param);               // store in variable
}

 

 

 

 

 

 

使用例子如下:

#include "lr_save_float.h"

vuser_init()

{
 lr_save_float(123.456, "myVar", 2);
 lr_output_message(lr_eval_string("{myVar}"));
 return 0;
}

转载地址:http://qynli.baihongyu.com/

你可能感兴趣的文章
php图像处理函数大全(缩放、剪裁、缩放、翻转、旋转、透明、锐化的实例总结)
查看>>
magento url中 uenc 一坨编码 base64
查看>>
强大的jQuery焦点图无缝滚动走马灯特效插件cxScroll
查看>>
Yii2.0 数据库查询
查看>>
yii2 db 操作
查看>>
mongodb group 有条件的过滤组合个数。
查看>>
yii2 用命令行操作web下的controller
查看>>
yii2 console的使用
查看>>
关于mongodb的 数组分组 array group
查看>>
MongoDB新的数据统计框架介绍
查看>>
mongodb fulltextsearch 关于语言的设置选项
查看>>
mongodb 增加全文检索索引
查看>>
symfony
查看>>
yourls 短连接 安装
查看>>
yii2 php namespace 引入第三方非namespace库文件时候,报错:Class not found 的解决
查看>>
softlayer 端口开放
查看>>
操作1:mongodb安装
查看>>
操作2:mongodb使用语法
查看>>
如何给分类增加一个属性(后台)
查看>>
linux设置环境变量 临时设置 和 永久设置
查看>>